What hook to add at start of WordPress load

The earliest hook accessible from external code is muplugins_loaded. In order to use it, create a directory mu-plugins in your wp-content directory and put a PHP file into that directory. Sample code, will have side effects(!): add_action( ‘muplugins_loaded’, function() { print current_filter(); }); This is, of course, not “before anything else in WordPress executes”. WordPress … Read more

Action hook with wrapper html

You want the has_action() function. add_action( ‘category_promo_header’, function () { echo ‘hi there’; } ); if (has_action(‘category_promo_header’)) { echo ‘<div>’; do_action(‘category_promo_header’); echo ‘</div>’; } Comment that add_action and you should see that nothing is printed at all.

Block Update Profile Errors

Solution: First, Jeff Farthing of theme-my-login pointed out that I was using add_filter instead of add_action, and helped to craft the first code below, however it still has the same problem, so this is a step in the right direction but is not my solution: function tml_profile_errors( &$errors ) { if ( empty( $_POST[‘state’] ) … Read more

Can an RSS item be altered with a hook?

the_content_feed is the hook I needed. In my case I am running a regex to replace relative URLs to absolute ones, so I added the following code to functions.php add_action(‘the_content_feed’, ‘relative_to_absolute_links’); function relative_to_absolute_links($content) { return preg_replace(“/(src=[‘\”]){1}\/{1}([^\/][^’\”]+)([‘\”])/im”, “$1” . get_site_url() . “/$2$3”, $content); }

Woocommerce single_product_summary hook not working

In your first code block try changing return $output; with echo $output; and that should work provided $output is not empty 🙂 If you are trying to append your custom field to the product summary, this can be very well achieved using woocommerce_short_description filter hook. Please see below code: function add_subtitle_to_product() { global $post; if … Read more

WP Cron not executing after timespan

Your custom hook is never triggered because you are not subscribing to it the right way! Context Although you are calling it in your class function, it is never executed beyond that point. Place the add_action function somewhere else like in a plugins_loaded hook. Put it outside your class where it can be seen. Dependencies … Read more

wp query add array by if condition

It looks like you are trying to access the $lava_listing_posts_args array from a different file (and class). You would need to pass it as an argument of your action. Although you could do this with actions since you are simply modifying the array you should probably use filters (actions and filters are essentially the same … Read more

Can not using get_header() cause trouble (later on)?

As long as the wp_head() function is still being called in the template, you should be fine. You’ve pretty much summed it up in your question; by not using get_header(), the get_header action will not be fired, but that wouldn’t matter for your particular use case. Using get_header() along with the name parameter would be … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)