We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Display ONLY appropriat posts

How Do I?

Russ K.'s avatar
Russ K.
114 posts
9 years ago
Russ K.'s avatar Russ K.

How do I display only blog posts with categories that match the category of my page?

I’ve been combing through the documentation & this seems like it should be simple, but…

R

       
Rob Allen's avatar
Rob Allen
2,950 posts
9 years ago
Rob Allen's avatar Rob Allen

If you’re on a category page (as dictated by the url which would be something like /template_group/category/category_url_title) then channel entries will by default only show entries that belong to that category.

       
Russ K.'s avatar
Russ K.
114 posts
9 years ago
Russ K.'s avatar Russ K.

Thats something I should have mentioned… I’m not on a category page, just a palin old channel entries page.

Thanks, Russ

       
Rob Allen's avatar
Rob Allen
2,950 posts
9 years ago
Rob Allen's avatar Rob Allen

In that case you could do it in several ways by using parameters in your channel entries tag:

Show all entries from any category belonging to a specific category group

{exp:channel:entries channel="mychannel" category_group="2"}

Show all entries from a specific category group and specific categories with ID’s 3,5,7 within:

{exp:channel:entries channel="mychannel" category_group="2" category="3|5|7"}

Show all entries from a specific category from any group

{exp:channel:entries channel="mychannel" category="3"}

Show all entries from several categories

{exp:channel:entries channel="mychannel" category="3|5|7"}

From the docs for reference: https://docs.expressionengine.com/latest/channel/channel_entries.html#id29 https://docs.expressionengine.com/latest/channel/channel_entries.html#id30

       
Russ K.'s avatar
Russ K.
114 posts
9 years ago
Russ K.'s avatar Russ K.

OK… Yeah… so I saw all of that, & I guess I’m on the right track then, but if my channel entry for products is assigned to categories 1,3, & 5,

How would I pass those ID’s into my Blog posts channel to display only blog posts in the sidebar that are assigned to those 3 categories?

Russ

       
Rob Allen's avatar
Rob Allen
2,950 posts
9 years ago
Rob Allen's avatar Rob Allen

Just use the category parameter like this.

{exp:channel:entries channel="mychannel" category="1|3|5" dynamic="no" limit="5"}

As its in your sidebar I’ve also added in the dynamic=no parameter to will ensure that EE doesn’t base results based on the URL segments, and a limit= parameter so you can lomit the number of entries displayed.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
9 years ago
Ingmar Greil's avatar Ingmar Greil

Have you considered related categories mode?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.