Articles of hooks

Woocommerce single_product_summary hook not working

I’m trying to add my own custom fields to the single product summary after the main product’s title output on my product page. I’ve looked into the woocommerce documentation (https://github.com/woothemes/woocommerce/blob/2.3.8/templates/content-single-product.php) and it looks like woocommerce_single_product_summary is my hook. So here’s what I did: // should hook into woocommerce single product summary and output info function […]

Action hook with wrapper html

I want to add a space for a banner across the top of my WooCommerce Category pages, but i’m trying to figure out how to add some markup that will wrap the action. In my archive-product.php I have the following code; <?php do_action(‘category_promo_header’); ?> Basically, if a Category has the ‘category_promo_header’ Action Hook Name set, […]

How to customize category_description()?

In a website I am working on ,there are 50 categories + sub categories, each has a a very long description text, then in an archive page I display all the titles of the categories + their description ,but it makes more sense to show the title of each category + a few words of […]

Update post meta using pending_to_publish hook

Below is my code for updating post meta. function changePostExpireDatetime( $post ){ $featurePlanID = get_post_meta($post->ID, ‘post_price_plan_id’, true ); remove_action(‘pending_to_publish’, ‘changePostExpireDatetime’, 10, 1); $plan_price = get_post_meta($featurePlanID, ‘plan_price’, true); update_post_meta($post->ID, ‘post_plan_price’, $plan_price ); update_post_meta($post->ID, ‘featured_post’, “1” ); add_action(‘pending_to_publish’, ‘changePostExpireDatetime’, 10, 1); } add_action(‘pending_to_publish’, ‘changePostExpireDatetime’, 10, 1); Function is called but meta is was not updated. How can […]

Returning ACF custom field from publish_post

I’m trying to return a custom field as soon as a post gets published. I’m using the publish_post (or {status}_{post_type}) action, but it looks like the custom fields are created after the hook. My code in functions.php: function create_recurring_posts( $ID, $post ) { logMe(print_r(get_post_custom($ID), true)); } add_action( ‘publish_profile’, ‘create_recurring_posts’, 10, 2 ); The logMe() function […]

Can an RSS item be altered with a hook?

I would like to alter the content of each item in a site’s RSS feed with a regular expression. The rss2_item hook is close but it is run just after the item has been output, so is only really useful for adding data to a feed item, I need to alter the item with a […]

WP_query hooks before execute a search query

Anybody knows if there’s a hook before execution of a search query (not in main loop) in order to change the ‘s’ parameter to avoid WordPress’ phrase splitting? Examples are welcome… thanks P.S.: I’ve also tried in this way as follow, but the first part of sql query seems to indicate that WP have already […]

Send admin to a different login than users?

I have created a separate login page on /login/ and have wp-login.php redirecting there as well – I have also hooked into a few WP login related hooks such as wp_login_failed so that people get redirected there. However I have now decided I want admins to continue to be able to login from the standard […]

Customize title, description and focused keyword

I would like to customize focused keyword, SEO title and meta description, but I am unable to find any clue how to do it. There is official documentation but it is sooo lacking… I came up with this for changing title, but this is directly changing the title for a page, it won’t affect meta […]

pre_get_comments or the_content filter

What is the best practice to show social icons always on all the posts and pages. Already I am firing pre_get_comments in my functions.php to show a sidebar between the post content and the comments. Also I added the code after the_content() of page.php… The Question: How can I choose the propper Hook? Fire pre_get_comments […]