Check $post->ID against multiple values

This is more of a PHP question than specifically WordPress, but you can use PHP’s in_array to test if $post->ID is in a bunch of values, like this: <?php if( in_array($post->ID, [13052, 1234, 4242]) ) { ?> <!– Event snippet for thank-you page –><script> gtag(‘event’, ‘conversion’, {‘send_to’: ‘AW-105871269/5v9gsts6dbdsJ-Kl’});</script> <?php } ?>

Query custom post type custom meta key

Now i got this code and i works. function get_events( ) { $recurrence_ids = get_post_custom_values( ‘_recurrence_id’ ); $recurrence_id = $recurrence_ids[0]; $the_query_args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘event’, ‘meta_key’ => ‘_recurrence_id’, ‘meta_value’ => $recurrence_id ); $the_query = new WP_Query( $the_query_args ); if ( $the_query->have_posts() ) { $output=”<div class=”weitere-termine”>”; while ( $the_query->have_posts() ) { $the_query->the_post(); … Read more

Send email to user when I publish a new post

Updated code for statuses as per @Fredrik’s answer as his is more accurate. To trigger this when publishing, you could change your first if to if ( $new_status === ‘inherit’ && $old_status === ‘new’ ) That way, your code should trigger only when you publish a post. EDIT: Some notes on your code. if ( … Read more