Load Javascript from Plugin in One Page Only?

Drop this in your functions.php or a custom plugin. function wpse_57621_alo_tidy() { if ( $page_id = get_option( ‘alo_em_subsc_page’ ) ) { if ( ! is_page( $page_id ) ) remove_action( ‘wp_head’, ‘alo_em_ajax_js’ ); } } add_action( ‘wp’, ‘wpse_57621_alo_tidy’ ); It’s attached to the wp hook, which runs just after the request has been handled & queried. … Read more

Does the lazyload plugin make this server disks busy?

You’ve provided no references to these claims people have made, and I can find no such claims on the support forum for the plugin linked to, but lets humour this theory and investigate. The bulk of the code is here in the PHP: http://plugins.svn.wordpress.org/lazy-load/trunk/lazy-load.php Judging from this I’d say that you might have some increased … Read more

List the authors that have written posts in a category

I found a solution. CODE: <?php $cat_arr = get_categories(); // Get the list of Categories foreach ($cat_arr as $cat_obj) { $term_id = $cat_obj->term_id; // Print the Name ?> <br> CAT NAME: <?php echo $cat_obj->name ?>, AUTHOR: <?php // Get all Posts of that Category $posts = get_posts(array(‘category’=>$term_id)); $authors_arr = array(); foreach ($posts as $post_obj) { … Read more

How to get the permanent link in a plugin?

globalize $post to get the current post’s data. also, you want get_permalink, which returns the permalink, rather than the_permalink, which directly echoes the permalink. function abcd_add_contents($content) { if (is_single()) { global $post; $extra_content = get_permalink( $post->ID ); $content .= $extra_content; } return $content; } add_filter(‘the_content’, ‘abcd_add_contents’);

get_option error plugin development

How plugins loading works WordPress has, as any other software, a specific order in which files get loaded. During loading WPs core files, there’re specific points where you can either hook into do_action() or alter data during apply_filters() calls. Those functions always get called with a minimum of one argument: The name. Sometimes there’re more … Read more

Can a plugin be run in a different language than WordPress?

Assuming the plugin makes use of localization at all, you could for example try exchanging the possible load_plugin_textdomain call with load_textdomain where you can point to the file you like. A cleaner way would be using the plugin_locale filter that let’s you modify the locale used by a plugin: function my_plugin_locale_filter($locale, $domain) { if($domain === … Read more

How to display price including tax with formatting?

Running any number through the function woocommerce_price() will format that number with the number of decimals, thousands separator, currency symbol and currency location chosen in the admin. Add the function to your code snippet should format the price correctly: <?php if ( $price_html = $product->get_price_including_tax() ): ?> <span class=”price”><?php echo woocommerce_price($price_html); ?></span>