Articles of hooks

Get post or page id early

Is there a good solution to get the queried object id really early … and i mean really early? I got a hook on after_setup_theme where i need to get the post or page id. $wp_query->queried_object_id is null at that point. I did it like so till now: function getID() { $actual_link = “http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”; $theID […]

Knowing if a post is sticky in the 'save_post' action. Where do I have to hook?

I’m using this plugin (FantasticElasticSearch) to index content when it’s published. So far it was strightforward and an easy task but, now that I tried to index a flag saying if a post is sticky, I’m having trouble and it’s being impossible. I’m changing the addOrUpdate function of the plugin to my profit, I’m adding […]

Modifying date filter on admin page for custom post type to link to custom field

Apologies if a similar question has already been asked, but I can’t seem to find the exact functionality I am looking for. Basically I have a custom post type (sermons) which has ‘recorded_date’ as a custom meta data field. What I would like to do is on the custom post admin page (where all posts […]

Make a custom column sortable by a value from a different custom post type

I’ve created some custom columns to display my custom post types more attractively in the admin section – the columns are mostly custom fields. Mostly, this works absolutely fine, and I can sort by the custom field columns as expected. However, one of the custom fields points to the post ID of a different post […]

Add a custom class to the body tag using custom fields

There are certain posts where I want to manually append a custom body class to using custom fields. How do I go about it appending the class to the body tag when a certain custom field is added to a post? I have tried the following but the custom fields name tagbody is not shown […]

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 ( 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 […]