• Im trying to load a single post content via Ajax with the get_post() function, as shown above

    $id = $_GET['id'];
      $post=get_post($id);
      $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'large');
      $author_id=$post->post_author;
      ?>
    <div style="background-image:url(<?php echo $thumb['0'] ?>)">
      <span><?php echo $post->post_title; ?></span>
      <a class="icon" data-icon="."></a>
    </div>
    <article>
    <div>por <a href="<?php get_author_posts_url($author_id); ?>"><?php the_author_meta('display_name', $author_id); ?></a></div>
    <?php echo $post->post_content; ?>
    </article>

    Also tried this variation and still it doesn’t work
    <?php echo sanitize_post_field( 'post_content', $post->post_content, $id, 'display' ); ?>

    But when I display $post->post_content; the Lightbox Plus plug-in does not initialize by itself. I’m wondering what’s the missing step to get this going

    This is what the post content looks like
    [gallery size="medium" link="file" ids="145,137,144,135,128,171,143,142,129,134,170,176,175,174,172,169"]

    You can check the site at https://guiasarquitecturasustentable.tk/ under “Proyectos” title (click on any proyect name and a modal should open, loading Ajax page that can be, for example, https://guiasarquitecturasustentable.tk/wordpress/wp-content/themes/guiasarq_1/page-ver-mas.php?feed=post&id=177 )
    https://www.ads-software.com/plugins/lightbox-plus/

  • The topic ‘How to initializate the Plug-in if using get_post() and Ajax’ is closed to new replies.