Forum

Thread tagged as: Question, Blog

How to exclude blog post I'm reading from aside column

Hi

On our blog posts we have an aside column which shows the latest 5 blog posts, using perch_blog_custom

I'm trying to exclude the post your currently viewing from displaying in the aside list. I've got so far...

$postID = PerchSystem::get_var('postID');
                perch_blog_custom(array(
                    'sort' => 'postDateTime',
                    'sort-order' => 'DESC',
                    'count' => 5,
                    'template' => 'blog-post-aside.html',
                    'filter' => 'postID',
                    'match' => 'neq',
                    'value' => $postID,
                ));

...but it's not working.

How do I pass postID to perch_blog_custom so it can filter out the current post you're reading from the aside column.

Many thanks

Glen Piggott

Glen Piggott 0 points

  • 1 week ago

Hello Glen,

Assuming you already know the slug of the current post (perhaps you're getting it with perch_get('s')), it would be easier to use it for your filter:

perch_blog_custom(array(
    'sort' => 'postDateTime',
    'sort-order' => 'DESC',
    'count' => 5,
    'template' => 'blog-post-aside.html',
    'filter' => 'postSlug',
    'match' => 'neq',
    'value' => perch_get('s'),
));