Forum Replies Created
Viewing 1 post (of 1 total)
-
AuthorPosts
-
December 16, 2023 at 11:36 am in reply to: Ajax wordpress : The data is not transmitted to the template #9915jennyParticipant
Here is your modify template-posts-container.php temaplte code, You should try
<div id="posts-container"> <?php foreach ($custom_posts as $post): setup_postdata($post); ?> <h2><?php echo esc_html(get_the_title($post)); ?></h2> <div class="post-content"><?php echo wp_kses_post(get_the_content(null, false, $post)); ?></div> <?php endforeach; wp_reset_postdata(); ?> </div>
setup_postdata($post) to set up global post data. This allows you to
use template tags like get_the_title() and get_the_content().
get_the_title($post) and get_the_content(null, false, $post) are used
to fetch the title and content of each post. -
AuthorPosts
Viewing 1 post (of 1 total)