Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

raj2005 on "want to link the posts on mywebsite back to it's own website where they live"

$
0
0

I have a website and want to display posts from an external website on to my own website so every times the posts update on the external website, it will update on my website too.

I have managed to pull the posts from the external website on to my website, but now I want them so that when you click them from my website they navigate to the original posts on the original website.

Please see my code below:

<?php
$mydb = new wpdb('root','','test','localhost');
$rows = $mydb->get_results("select post_title from wp_posts");
echo '<ul>';
foreach ($rows as $obj) :
   echo '<li><a href="'.get_permalink($obj->post_title).'">'.$obj->post_title.'</a></li>';
endforeach;
echo '</ul>';
?>

ThE_ED on "(re)load Lightbox scripts after I load more content"

$
0
0

I'm developing a small plugin to support some authors. Basically, it loads a (single page style) article page as normal, but cuts short its content and replaces that with a button. That button then loads the rest of the content, after being clicked. (It checks more stuff, of course.)

Now, my problem is that a lot of lightbox-like script replace or add classnames to images and other content.

Those scripts have of course already run before my script ever runs.

Thus: they don't work because those replacements are never done on the classnames that go with possible additional images. (To name one mediatype.)

What would be a good way to approach this and get as much scripts as possible to (re)load as possible after my button has done it's task? (It's fairly easy to just reload a single script that I know about, but I don't know what kind of plugins each author runs on their site, of course.)

Could I just get the page to fire a new document.ready status and hope for the best?

jschnyderite on "Custom shop page"

$
0
0

I am looking to create a custom shop page that will display Category title, description, then items within that category, then on to the next category title, description, etc.

I'm not a programmer, but I'm assuming i need to edit the product archive file and put some php that pulls title and description info and put that inside a loop.

Are there variables for this already defined for woocommerce? Any guidance on how to do this would be appreciated -- or if there is a better way, im open to options.

Thanks!!

devonanne on "Limit list of post titles to single catgegory?"

$
0
0

I'm using this code on a custom template to display a list of post titles:

<ul class="category-list">
<?php
// we add this, to show all posts in our
// Glossary sorted alphabetically
$args = array( 'posts_per_page' => -1, 'orderby'=> 'title', 'order' => 'ASC' );
$glossaryposts = get_posts( $args );
// here comes The Loop!
foreach( $glossaryposts as $post ) :	setup_postdata($post);  ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

This works nicely, however I want to limit my list to a certain category. I've found other solutions for doing this, but not one that works with the code I currently have. How can I modify this to limit my list to a specific category?

melissasms on "Custom Post Types"

$
0
0

I was asked to add a blog to an existing Wordpress installation. The problem is the "posts" category has been renamed, customized, and functions entirely different from the default set-up. The previous developer set up the website nicely, but I am not sure if adding a blog to their existing site is possible. They seemed to use the "Advanced Custom Fields" plug-in as well as custom functions in the back-end to give the posts area new functionality. If I go to edit a post (which is now called a resource), I don't get a text field where the content usually goes and see new areas for uploading material.

Website for reference: http://www.sani-care.com
The individual materials under the dealers section is currently what is set-up as "posts".

My question is how can I add a blog if the default posts section has been modified to such an extent? Is there anyway to duplicate the "posts" section of Wordpress?

graham333 on "Adding Navbar to Page.php - Nearly, but no style or dropdown - Help:-)"

$
0
0

Hope this is in the right place.

I am trying do this without knowing if it's possible (as usual haha) but what I have done so far seems to work up to a point.

I'm using the 2012 theme (with child) what I want to do is put the standard navbar menu on the home page template ONLY.

So taking the bull by the horns, I took the navbar code from the header.php file and pasted it into the page-templates/front-page.php and thought that would do the trick (poor fool that I am)

Although it has worked somewhat in that it has put all the navigation links in a vertical list on the front-page.php but...

... unlike me I'm sure you coders will know what the problem is going to be viz...

I have lost the horizontal style from the css somewhere along the way and of course the menu Javascript is not working either.

Yet again I have no idea how to put this right, if some valiant soul can please help me get this working correctly I will be eternally grateful.
Apart from jumping off a bridge, what are my next steps?

======================

This is the code snippet from the header.php I pasted in

<nav id="site-navigation" class="main-navigation" role="navigation">
			<button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button>
			<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
			<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
		</nav><!-- #site-navigation -->

this is the code that is in the front page.php template to save you lookinh it up.

<?php
/**
 * Template Name: Front Page Template
 *
 * Description: A page template that provides a key component of WordPress as a CMS
 * by meeting the need for a carefully crafted introductory page. The front page template
 * in Twenty Twelve consists of a page content area for adding text, images, video --
 * anything you'd like -- followed by front-page-only widgets in one or two columns.
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */

get_header(); ?>

	<div id="primary" class="site-content">
		<div id="content" role="main">

			<?php while ( have_posts() ) : the_post(); ?>
				<?php if ( has_post_thumbnail() ) : ?>
					<div class="entry-page-image">
						<?php the_post_thumbnail(); ?>
					</div><!-- .entry-page-image -->
				<?php endif; ?>

				<?php get_template_part( 'content', 'page' ); ?>

			<?php endwhile; // end of the loop. ?>

		</div><!-- #content -->
	</div><!-- #primary -->

<?php get_sidebar( 'front' ); ?>
<?php get_footer(); ?>

and this is where I have pasted the header code into front page.php

get_header(); ?>

<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>

<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>

<nav id="site-navigation" class="main-navigation" role="navigation">
			<button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button>
			<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"></nav><!-- #site-navigation -->

<?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
</nav><!-- #site-navigation -->

	<div id="primary" class="site-content">
		<div id="content" role="main">

			<?php while ( have_posts() ) : the_post(); ?>
				<?php if ( has_post_thumbnail() ) : ?>
					<div class="entry-page-image">
						<?php the_post_thumbnail(); ?>
					</div><!-- .entry-page-image -->
				<?php endif; ?>

				<?php get_template_part( 'content', 'page' ); ?>

			<?php endwhile; // end of the loop. ?>

		</div><!-- #content -->
	</div><!-- #primary -->

Standing by, but not holding my breath in case I have posted in the wrong place :-D

notarobot40 on "limit add_filter to comments by date"

$
0
0

Hi, I am looking for help with a hack for this plugin:

https://wordpress.org/plugins/wp-unread-comments/

The plugin highlights unread comments in post threads. It uses a cookie with time stamps to limit the highlights to comments posted since the user last visited the page. The sidebar widget then generates a list of posts (last set at 3) with unread comments for each user.

The site is: http://rrhelections.com/

The issue appeared when we migrated the archive of posts from the old Soapblox site to the WordPress site, which added thousands of "unread" posts. The sidebar widget (currently inactive) now fails to show anything, hides everything below it in the sidebar, and also hides the dashboard toolbar.

It seems the best solution would be to limit the add_filter in the last line of code below to comments posted within the past 30 days, rather than add the action to every comment.

*/

require_once(dirname(__FILE__) . '/includes/class-wp-uc-widget.php');
$wp_uc = new WP_UC_Widget();

//widget
add_action('widgets_init', 'wp_unread_comments_init');

//register the functions
add_action('wuc_get_time', 'wuc_get_time');
add_action('wuc_set_time', 'wuc_set_time');

// Add the action to every comment
add_filter('comment_class', 'wuc_unread_class', 10);

I've tried several ways to define a narrower class of comments but clearly my coding skill is inadequate. I will greatly appreciate any help with this! Thanks!!

mikek12003 on "Replace dropdown lang selection with flags one next to the other"

$
0
0

So I got a wp install and a theme and installed
http://wordpress.org/extend/plugins/polylang/ ( which is a great plugin! ) after 5mins of settings modifications i had a nice 2 lang site with a dropdown with the flags I have chosen (not inserted any lang switcher in my menu ) it was a nice dropdown located in #Top_bar .top_bar_right (went there by itself no problems with it). My only problem is that i do not want a select element, just the flags one after the other (I have only 2 languages so no space issues).
So basically if i can replace the select HTML element with the contents of its options, one after the other i will be happy. For now i did a hack where I hidden the #Top_bar .top_bar_right element, put the flags in the menus and modified the css for those li a span, but this does not seem like a very clean solution.
PS. I also changed the flags icons cause they were really small with bigger ones -worked like a charm.


tech55541 on "Add Login link to menu"

$
0
0

Hello all,
I would like to add a login logout link to my menu. I have used this code for my footer link, but do not know how to make this work with the menu.

<?php
if ( is_user_logged_in() ) {
    echo '<a href="' . wp_logout_url( get_permalink() ) . '" title="Logout">Log Out</a>';
} else {
    echo '<a href="' . wp_login_url( get_permalink() ) . '" title="Login Or Register">Log In</a>';
}

The trick is I would like the login and logout links to take the user back to the page they were previously on when they clicked the login link.
If it is possible to only do this for subscribers, that would be even better.

Any suggestions?

theZman on "Need GLOBAL var to detect "If Appearance Customize Screen" is ON"

$
0
0

Problem:
When admin is using 'Appearance Customize Screen' via the theme sub menu Appearance->customize there appears to be no way to detect if "is_customiser" is true/false via the theme layer.

Consider the following:
Lets say an Admin is customizing a site that has sub pages, they change a color within the customer section that only applies to a subpage. We have no way to preview that change on any other page other than the "homepage".

Possible solution:
create a boolean such as "is_customiser" where as we could easily include the additional layouts on the home page in a "preview detected mode"

some tests and attempts:
I tried this in Functions.php

function mytheme_customizer_live_preview(){
        global $_customiser;
        $_customiser = TRUE; //<- this works
        echo "bar"; //<- this works, but dumps prior to head
}
add_action( 'customize_preview_init', 'mytheme_customizer_live_preview' );

and then in header.php

global $_customiser;
if( $_customiser){ echo "foo"; //<- this works}

And thats good and fine if I want to push a bunch of ODB into a var and have a really really long homepage...
However this becomes quite ineffective with lets say a 10 template and 5 custom post_type multi taxonomy site...

Simply put: we need a way to accomplish any or all of the following

  • A: better way to detect if the customizer is active...
    and if so, then show things that are not on the homepage.
  • B: make the customizer work on subpages,
    where as a user is in Appearance->customize and clicks on a subpage the customizer needs to know that and load options there too...
  • C: possibly create some new hook, or, allow us to feed information back to the customiser from inside our iFrame?

Please feel free to suggest alternatives, I have reviewed the documentation but maybe there is another way I do not know of?

thank you for your consideration and examination of this matter.

megafreechips on "Calypso on Self-Hosted Site."

$
0
0

Anyone already running Calypso with a self-hosted site?
Nice to hear some insights if anyone tried that out...
Would be also awesome to see major plugins like ACF & Yoast adapt to this major change.
Cheers.

graham333 on "Home Page only Header Image - Syntax Check please - 2012"

$
0
0

Hi folks,
I'm still struggling away but am nearly there with my theme, just need some help with this one last thing...

Details:

Theme 2012 with child
Home page is the 2012 Page template... front-page.php
The Home page ID is (2)

Problem:

All I need to do is show the header image on the front page only and nowhere else.

I thought conditional tags are the way to go but the various combinations of code snippets I tried broke the site each time.

I have tried...

<?php if ( is_front_page() && $header_image ) :
<?php if ( is_front_page() && $get_header_image ) :
<?php if ( is_page( 2 ) ( get_header_image() ) : ?>

in place of the line...
<?php if ( get_header_image() ) : ?>

Maybe one of them is correct but perhaps I am missing something important,
Could one of you coding ninjas please supply the correct syntax for me that will work with this theme/template.

Here is the header image code from the 2012 header.php default to save you looking it up...
<stuff>
</nav><!-- #site-navigation -->

<?php if ( get_header_image() ) : ?>

"><img src="<?php header_image(); ?>" class="header-image"
width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header
()->height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" />
`

<?php endif; ?>

</header><!-- #masthead -->
<div id="main" class="wrapper">`

AeonOfTime on "Safeguarding local plugin files during upgrade"

$
0
0

My plugin has a screenshots collection that has to be downloaded separately, as it would be too big to include in the plugin. Problem is, this gets deleted each time the plugin gets updated.

I could not find any official guidelines regarding this, but proposed solutions I found were, for example:

  • Storing the files in the uploads/ folder
  • Creating a custom plugin for the files
  • Add a backup/restore function that can be used manually to move the files out of the way for the duration of the upgrade

What would you recommend?

Regards,

Aeon.

ronnyrook on "Adding table options to TinyMCE editor without plug-in"

$
0
0

Hi guys,

I would like to add the table options to my TinyMCE editor without using the TinyMCE Advanced plug-in. Is there a way I can do this? Thanks in forward.

Greetings!

aggass2001 on "classified site how to use cloudfare rocket loader on catagory section"

$
0
0

i am using rocket loader on normal pages and wordpress plugin orginizer

how can i use plugin orginizer on catagory section
http://example.com/classifieds
this section dont have a page to it so how can i use plugin orginizer on this


ajardmedia on "Brute force list firewall"

$
0
0

Last thursday I forgot my password from my website, but I wanted to try it anyway Because I thought I could it find out.

unfortunately Know when I want to go to the website or to the backend off the website, de website times for ever to load and at the end there is a page that says that he load to long.

Friends and family can load the website, zo it's not the website itself.
In every browser I tried it and also in incognito mode. And if I shut down the wifi on my phone that's connected with the wifi in my house I can upload the website with my mobile network.

I really have no idea how I can come out of this brute force list in my firewall, so if someone has information or dvice on how I can run my website at home again, I would appreciate it.

Thanks in advance!!!

javasworks on "WooCommerce's hook that runs on update_checkout or update_order_review"

$
0
0

So, the checkout page has Cash On Delivery & Direct Bank Transfer payment method. The goal is to make to make no shipping method available or to make free shipping to be the only available method when the COD payment_method radio is checked. I need to unset jne_shipping shipping method.

I add callback to the payment_method radio change event:

$('input[name=payment_method]').change(function() {
  // request update_checkout to domain.com/checkout/?wc-ajax=update_order_review
  $('body').trigger('update_checkout');
});

and the hook in php:

add_filter( 'woocommerce_available_shipping_methods', 'freeOnCOD', 10, 1 );
function freeOnCOD($available_methods)
{
    if ( isset( $_POST['payment_method'] ) && $_POST['payment_method'] === 'cod' ) {
        unset( $available_methods['jne_shipping'] );
    }

    return $available_methods;
}

But this filter hook even doesn't run. I also try woocommerce_package_rates but still no effect.

Ofcourse, i also checked the WooCommerce's hooks documentation but can't figure what is the correct hook that runs on update_checkout or update_order_review

nyhelp appreciated

mstdmstd on "js-methods with prefix specified"

$
0
0

Hi all,
I have wordpress plugin with js-file attached for js functions.
I want to escape possible error of having js functions with the same name as js functions pf other developers so I use some prefix like "nsnpas_" in functions name and inputs name.
This prefix I define as php constant

define( 'nsnPluginPrefix', 'nsnpas_' );

and use it like :

<script type="text/javascript" language="JavaScript">
    /*<![CDATA[*/
    ...
    var <?php echo nsnPluginPrefix ?>obj_productsAjaxSearchBox = new <?php echo nsnPluginPrefix ?>productsAjaxSearchBox(  { nsnPluginPrefix : 'nsnpas_', ...   },
        use_in_search_array, autocomplete_save_options_as_array );  // That is object's ref to my js functions
    ...
            <input value="<?php echo get_search_query() ?>" name="input_<?php echo nsnPluginPrefix ?>search" id="input_<?php echo nsnPluginPrefix ?>search" class=""  placeholder="Type search" />&nbsp;
   ...

            <img src="<?php echo $plugin_url ?>images/arrow-down.png" alt="Open Options" title="<?php echo esc_html__("Open Options") ?> style="cursor: pointer;"  onclick="javascript:<?php echo nsnPluginPrefix ?>obj_productsAjaxSearchBox.openOptions();">  <!-- margin-left: 10px; width: 16px;height: 16px; -->

and in my js file ti which I set nsnPluginPrefix as:

...

var this_m_nsnPluginPrefix;

function nsnpas_productsAjaxSearchBox(Params, use_in_search_array, autocomplete_save_options_as_array) {  // constructor of backend artist's editor - set all params from server
    selfproductsAjaxSearchBox = this;
    this_m_nsnPluginPrefix = Params.nsnPluginPrefix;
    this_plugin_url = Params.plugin_url;
    ...
}

nsnpas_productsAjaxSearchBox.prototype.openOptions = function () {
    $( "#span_"+this_m_nsnPluginPrefix+"openOptions").css("display","none")
    $( "#span_"+this_m_nsnPluginPrefix+"hideOptions").css("display","inline")
    $( "#div_"+this_m_nsnPluginPrefix+"ajaxSearchOptions").css("display","inline")
}

It works for me. but I have to write function's object as literal "nsnpas_". I mean If I need to change nsnPluginPrefix contant, I would have to change "nsnpas_" literal by hand in all js file.
If there is a way to generate this prefix programmatically in js file or can this be salved i some different way?

Thanks!

Navia Ang on "Modify Header Image become 3 images"

$
0
0

I'm using Twenty Thirteen Theme, I like to change my header image become 3 images, maybe using bootstrap's Fluid Grid System 2-8-2 with responsive, like

|-- image1--| -------- image2-------- | --image3--|
<------2----><-----------8------------><----2----->

And how to make it max-width : 1080px and height : 80px.

Thanks for advices.

intrepidweb on "Image Attachment Database Entries"

$
0
0

Anyone know of any consequences to manually changing the "post_name" value for image attachments in the "posts" table? I would be doing this manually in the database itself. Is the "post_name" field for attachments really used for anything other than within the attachment page URLs?

Viewing all 8245 articles
Browse latest View live




Latest Images