Filter Archive Posts Display by Category

Hi all,

I have an Archive Layout set to only display posts that have a particular category assigned to them.

Currently my settings are:

{{dc:term:category}} is knowledge base (which is the name of the category. Incidentally, this is also set as the ‘default’ WP post category).

Anyway, I now have a new post category (newsletter) which should not be displayed in the archive layout. But for some reason it’s appearing - even though it hasn’t got a knowledge base category assigned to it.

I changed the condition group to

{{dc:term:category}} is knowledge base AND
{{dc:term:category}} is not newsletter

However, that didn’t change anything.

I tried changing the second condition to {{dc:term:name}} or {{dc:term:slug}} instead, but they didn’t work either.

The Looper Provider is set to “Recent Posts” and I’ve tried clearing WP cache, etc. Running the latest versions of WP and X.

Any help/guidance you can provide would be greatly appreciated.

Hey @KEXINO,

It’s not clear why the issue is happening based on the current info. Please provide the following info in a Secure Note so we could check the actual setup.

  • WordPress Login URL
  • Admin username and password
  • URL of the page with issue

You can find the Secure Note button at the bottom of your posts.

Thanks.

Secure note and details of how to find the issue are attached,

Hi @KEXINO,

I have checked the specific category archive page and found that the Base Layout (KB, Archive Page) is assigned to it. I have checked and set the priority to the KB_ARCHIVE_LAYOUT HOMEPAGE layout lesser than the global one and now it is working as expected.

Thanks

Thanks, but I’m looking at the front end of the site right now and still see a post with the “newsletter” category.

Hi @KEXINO,

You can check the following Archive Page where the posts under the knowledge base category are shown. You can see a total of 48 pagination with 20 posts per page coming up and the category has 944 total posts.

Can you please specify any post or posts that are coming up in this layout from newsletter category. And also check if that have multiple category assigned.

Thanks

Sure. I’ve highlighted 2 posts, each one assigned just the “newsletter” category, that are appearing at the front end (when they shouldn’t).

Hello @KEXINO,

Are you trying the use the “KB_Archive_Layout Homepage” as the default layout of your Knowledge Base category archive page? If that is the case, your condition should be:

Then you will have to disable the Looper Provider. Always keep in mind that when creating any custom archive layout, you do not need to have a Looper Provider. WordPress runs its own loop in an archive page.

Hope this makes sense. Kindly let us know how it goes.

I’ve made the changes you advised.

The posts with the “newsletter” category are still showing up (e.g. post dated September 16, or post dated August 22).

Please advise.

Hi @KEXINO,

I do not see any other post with a different category on this page:

Thanks.

You’re right! Thanks.

When I look at the archive page in Cornerstone the display is different. I see posts without the “knowledge base” category" appearing there. Is that normal?

Hello @KEXINO,

Just make sure to assign the category in the preview assignment:

Best Regards.

OK will do.

Many thanks!

Hi @KEXINO,

You are most welcome.

Sorry guys, I still have an issue.

The category archive page now works fine. However the Looper on the homepage is still pulling in posts with the “newsletter” category.

When I add {{dc:term:category}} is knowledge base to the “Latest Posts” looper on the homepage everything disappears.

What am I doing wrong?

To clarify, the native WP category pages work fine. It’s the custom KB page with the looper that is not working correctly.

https://inkjetinsight.com/category/knowledge-base/ has no posts showing up that have the “Newsletter” category (which is what I want) but https://inkjetinsight.com/knowledge-base/ has them there.

Hello @KEXINO,

First, you have a slug conflict. Both your Knowledge Base category and the Knowledge Base page have the same slug.

Second, you have assigned your Knowledge Base page as your Posts Page or blog index in Settings > Reading:

Please be informed that the blog index will display all the latest post items regardless of the assigned category and tag in chronological order. If you only want to exclude a category in your blog index, you may need to check this article instead:

Be advised that custom coding is beyond the scope of our support under our Support Policy. If you are unfamiliar with code and resolving potential conflicts, you may select our One service for further assistance.

Best Regards.

Thanks for the clarification. I wasn’t aware that a page assigned as the blog index page can’t hide posts by category.

Hello @KEXINO,

If you want to exclude a category from your WordPress index, you can check out this article:

Cheers.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.