Home › Forums › Backend Issues (wp-admin) › get_the_content returning no content even though it exists › Reply To: get_the_content returning no content even though it exists
You should just be able to use: <?php the_title(); ?>
and <?php the_content(); ?>
Just ensure you use setup_postdata( $post );
in the loop, for example:
<?php
$faqtest = get_posts(array(
'post_type' => 'faqs',
'posts_per_page' => 25,
'meta_query' => array(
array(
'key' => 'associated_service', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exactly</code>"123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
),
));
if ( $faqtest ) {
foreach ( $faqtest as $post ) :
setup_postdata( $post ); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content(); ?>
<?php
endforeach;
wp_reset_postdata();
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
✨ You can now install ACF PRO with Composer, eliminating the need for third-party installers. Get the details and instructions here. https://t.co/ebEfp60Pwj
— Advanced Custom Fields (@wp_acf) February 2, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.