Set Transient on CPT

Submitting a full blown answer now that we’ve figured it out. Transients can be hard to troubleshoot because if you save the wrong value to the database at first, you can be looking at an old—and bad—value, even if the code that sets your transient is now correct. The two ways you can fix this … Read more

Skip posts, but keep posts per page

Use pre_get_posts to add a meta query to the main query: function wpd_date_meta_query( $query ) { if( $query->is_post_type_archive( ‘your_post_type’ ) && $query->is_main_query() ){ $meta_query = array( array( ‘key’ => ‘Date’, ‘value’ => date(‘Ymd’), ‘compare’ => ‘>=’, ‘type’ => ‘NUMERIC’ ) ); $query->set( ‘meta_query’, $meta_query ); $query->set( ‘meta_key’, ‘Date’ ); $query->set( ‘orderby’, ‘meta_value_num’ ); $query->set( ‘order’, … Read more

How can I modify this code to iterate over an array of categories?

In short, yes! $args = array( ‘post_type’ => ‘summerartcamp’, ‘cat’ => 15, //This is for the Morning Group – I’ll have a second loop for the Afternoon Group ‘order’ => ‘ASC’, ‘meta_key’ => ‘_expiration-date’, ‘orderby’ => ‘meta_value’ ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() /* Make sure you use the method, not … Read more

Pagination on custom post types

Change $loop = new WP_Query( array( ‘post_type’ => ‘portfolio’, ‘posts_per_page’ => -1 ) ); to e.g. $loop = new WP_Query( array( ‘post_type’ => ‘portfolio’, ‘posts_per_page’ => 9 ) ); If you set posts_per_page to -1 you will always pull all available posts. Hence, no pagination will show up since all posts are already shown on … Read more

WP_Query a custom field value bringing back 0 results

UPDATE: Ok this should work, according to ACF’s documentation: $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘page’, ‘meta_query’ => array( array( ‘key’ => ‘feature_on_front_page’, ‘value’ => ‘featured’, ‘compare’ => ‘LIKE’ ), ) ); Your code works for me. Can you see the feature_on_front_page custom field when you view the page(s) in the WordPress admin … Read more

How to loop through a custom field for each post, & display?

You are missing “foreach” loop. Try this way $latest_cpt = get_posts(“post_type=event”); foreach ( $latest_cpt as $cpt_post ) { $theidone =$cpt_post->ID; $this_post_id = $theidone; //get_the_ID(); $key_2_value = get_post_meta( $this_post_id, ‘custom_select’, true ); if( ! empty( $key_2_value )) { $thisisworking = $key_2_value ; ;} echo $thisisworking; }

Create Customization Controls from Array

Please add “;” after $i = $i++ and see if that fixes your issue foreach ($socialIcons as $icon) { $i = $i++; $wp_customize->add_setting( ‘pxk_href_’ . $icon[‘name’], // use this in twig file call to theme_mod array( ‘default’ => ”, ‘transport’ => ‘postMessage’, ‘priority’ => $i ) );