changing variable through filters or action hooks

It won’t work the way you are doing it, but you are close. The reason you have to use a global is that you aren’t setting your $meta variable with the information returned from the filter. This: do_action(‘alter_loop’,$meta); Should be this: $meta = apply_filters(‘alter_loop’,$meta); Note: “Actions” do not return values. “Actions” do things. “Filters” accept … Read more

delay function on publish?

publish_post is called after post is published! So, you already got covered. but if you want to run an action after a certain time of the post is published, it’s better to write a cron job. For example, if you need to run the function after 5 minutes of the post is published, you need … Read more

Custom post type archive sorted and grouped by date in post meta field

OK, so this problem has two parts: Make WordPress to sort these posts properly. Make WordPress to display them with all that grouping. 1. Sorting CPT by meta value on archive You can use pre_get_posts to achieve this. add_action( ‘pre_get_posts’, function ( $query ) { if ( is_post_type_archive( ‘event’ ) && $query->is_main_query() ) { $query->set( … Read more