[Special Summer Sale] 40% OFF All Magento 2 Themes

Cart

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: Ajax wordpress : The data is not transmitted to the template #9915
    jenny
    Participant

    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.

Viewing 1 post (of 1 total)