ACF: using two loops, the_field returns field content from another loop

I’m not fun of helper functions so I would write it like this: $args=array( ‘post_type’ => ‘post’, ‘posts_per_page’ => ’20’, ‘post_status’ => ‘publish’, ‘order’=>’DESC’, ‘orderby’=>’ID’, ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); $current_id = $post->ID; echo the_field(‘field1’, $current_id); } wp_reset_postdata(); } else { // … Read more

Separate by Category Post Type

To get custom post type posts with specific category use custom taxonomy Register the taxonomy name of the custom post type like location and then assign location to each post when you added new post. Here is the example of the code add_action( ‘init’, ‘hotels_my_taxonomy’); function hotels_my_taxonomy(){ // custom post type taxonomies $labels = array( … Read more

query all posts published by certain user id

You are querying for post author with ID 8 and also you are telling to match the post type to property post type and also post_status to be either publish, acf-disabled, private. Check your post that didn’t be return for the above and will found the reason. SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND … Read more

Double loop output

By inspecting your code, it appears those are two separate featured posts, rather than a single one with the author being duplicated. The first one being: Is Marketing Operations The New Industry Buzzword? And the second one being: Why The CMO Is The CEO’s Super-Weapon This might be trivial – but have you double checked … Read more

Query string order by custom field

The query_posts is only useful when you actually know what you are doing. Base on the info you provide this should work for you : $the_query = new WP_Query(array( ‘post_type’ => ‘your_cpt’, ‘posts_per_page’ => -1,//get them all ‘meta_key’ => ‘field_4’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’ )); ?> <?php if( $the_query->have_posts() ): ?> <ul> <?php … Read more