• Resolved robpinney

    (@robpinney)


    I’m trying to use ALM at the bottom of single posts to load a couple of other items, but I can’t figure out how to exclude the current post ID (which will change). There is another thread on this already, but I’m struggling to adapt that code.

    The shortcode I need to use is: [ajax_load_more post_type="post" orderby="rand" posts_per_page="2" pause="true" max_pages="0" transition="fade" button_label="More"]

    Any help greatly appreciated!

    https://www.ads-software.com/plugins/ajax-load-more/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi Rob,
    You need to store the current post id in a variable and then pass down the page to the shortcode.

    in your single loop at the top of the page…

    <?php $exclude = get_the_ID(); // the post id ?>

    and now the ALM part…

    <?php echo do_shortcode('[ajax_load_more post_type="post" orderby="rand" posts_per_page="2" exclude="' . $exclude . '" pause="true" max_pages="0" transition="fade" button_label="More"]') ?>

    Thread Starter robpinney

    (@robpinney)

    Thank you so much! That’s the quickest and best support I could possibly have hoped for.

    The only problem left is that it isn’t loading a custom field (‘location’) – is there a way to get it to pull this data also?

    Thanks again.

    Plugin Author Darren Cooney

    (@dcooney)

    Define global $post; in your repeater template after the opening html tag.

    Feel free to leave me a review ??
    https://www.ads-software.com/support/view/plugin-reviews/ajax-load-more

    Thread Starter robpinney

    (@robpinney)

    Indredible, thank you! I’ll be sure to leave a review.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude current post ID dynamically’ is closed to new replies.