Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 210725

How loop trough Custom Post Types content including the_field

$
0
0

Replies: 1

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 all articles
Browse latest Browse all 210725

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>