Exclude current/active blog post article from perch blog recent posts

  • While using Perch Blog I have decided that on each post.php page I want to include the latest 3 blog posts underneath my main post.

    I'm using code:


    PHP
    1. <?php
    2. perch_blog_recent_posts(3);
    3. ?>

    But if I am viewing one of the 3 latest posts then the post still appears in the latest 3 (As it is technically one of the latest 3). Is there anyway to exclude the current post that I'm on from the recent posts list?

  • I think you can use:


    Code
    1. perch_blog_custom([
    2. 'count' => 3,
    3. 'filter' => 'postSlug',
    4. 'match' => 'neq',
    5. 'value' => perch_get('s'),
    6. 'sort' => 'postDateTime',
    7. 'sort-order'=> 'DESC',
    8. ]);


    So it will display 3 posts, sorted by most recent date, excluding the post with the slug you are viewing.