We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Blog

Exclude blogs from list

I am using this code to get the blogs:

                        $articles = perch_blog_custom( array(
                            'skip-template' => true,
                            'count' => 10,
                            'paginate' => false,
                            'return-html' => false
                        ), true );

But I want to exclude 3 blogs from this $articles array which are showing at the slider of page. Please help how can it be implemented.

Thanks,

Bhashkar Yadav

Bhashkar Yadav 0 points

  • 2 years ago

Hi Bhashkar

Could you add a category to the posts you want to exclude, then add this to your perch_blog_custom;

'category' => array('!mycategory'),

Simon Clay

Simon Clay 127 points

Is it the first 3 blog posts you want to exclude?

If it is, you can use 'start' => 4

The problem is that my blog page is showing a slider at the top of the page and this slider is containing latest blog from each category. For example - if I am having 3 categories "Cat 1", "Cat 2" and "Cat 3", the "Blog - Cat 1", "Blog - Cat 2" and "Blog - Cat 3" will be within slider. Now I 'd like to exclude these 3 blogs from blog listing on this page.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you trying to filter blogs or blog posts here?

Thanks Drew,

I am not filtering blogs. Just would like to exclude 3 blogs from blog listing. Is it possible is I can exclude by "BLOG ID"?

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Bhashkar,

It's not 100% clear what you want to do.

Just would like to exclude 3 blogs from blog listing

So we are on the same page: blog is not the same as blog post.

Based on your other comment it seems you want to exclude the most recent blog post from each category (because they are already displayed in a slider on the page). Is this correct?

I am not filtering blogs. Just would like to exclude 3 blogs from blog listing.

The easiest way to exclude blog posts from a listing is often by filtering with perch_blog_custom().


my blog page is showing a slider at the top of the page and this slider is containing latest blog from each category

If you are already adding the blog posts you want to exclude somewhere else on the page, you may be able to use the information you already have to exclude them from the listing. You probably can grab the postSlug for each and use that for filtering.

How are you adding the latest blog posts from each category to the slider?