How loop trough Custom Post Types content including the_field
-
Hi guys recently I had a task to loop trough Custom Post Types like menus and get the content of each post like menu.
So I made this code<?php $args = array( 'post_type' => 'menus' , 'posts_per_page' => 4 ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : ?> <div id="owl-demo" class="owl-carousel owl-theme"> <?php while ( $the_query->have_posts() ) { ?> <?php $the_query->the_post(); ?> <div class="item"> <?php the_title(); the_content()?> </div> <?php };?> <?php wp_reset_postdata(); ?> <?php else: ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?> </div>
The thing is that this brings only the title of post. I use ACF plugin’s function as the_field(). And put all my post’s code in one single_menus code. Is it right way? What kind of solution yuo can give. Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How loop trough Custom Post Types content including the_field’ is closed to new replies.