3

I have a category (cat1) with 2 sub-cats (cat1a and cat1b). 19 entries belong to cat1, but 9 are in the sub-cats.

On the 1st level category page (cat1) is there a way to not show the 9 entries that are in the sub-cats?

Sub-categories aren't set in stone either, meaning client will add more sub-cats periodically.

Channel entry tag is being used by the way.

Thanks

3 Answers 3

5

You may have Auto-Assign Category Parents turned on, which automatically assigns the category parent when you choose a child category on save. So when viewing Cat1, all of Cat1a entries will also be displayed since the parent category is automatically set.

To turn off, go to Admin > Channel Admin > Global Channel Preferences.

Also, you will need to then go and update the 9 entries and remove the parent category. You can do this in bulk from the edit entries page. Find all 9 entries, click the checkbox next to each, then at the bottom, choose remove categories. Select the category parent to be removed.

1
  • I knew I was forgetting something stupid.
    – Tad Ward
    Jan 11, 2013 at 2:47
3

Unless I've missed something here could you not simply use the parent_only="yes" paramater on the channel categories tag?

http://ellislab.com/expressionengine/user-guide/modules/channel/categories.html#parent-only

If you were looking to do something slightly more complex you could always try the GWcode Categories plugin http://gwcode.com/add-ons/gwcode-categories

1
  • Sorry forgot to mention its the channel entries tag i am using, so no parent_only parameter.
    – Tad Ward
    Jan 11, 2013 at 2:46
0

One answer here (as mentioned) is to disable Auto-Assign Category Parents.

But, on a site where i rely on that setting to be available, i display the entry conditionally inside the categories tag. Say you want entries for category id 20 only, not children of 20, then i use a condition (or switchee) on the parent_id:

{!-- preload replace trick with segment conditional to set default --}
{if segment_2_category_id ==""}
  {preload_replace:my_cat_id="12"}
{/if}
{preload_replace:my_cat_id="{segment_2_category_id}"}


{exp:channel entries category="{my_cat_id}" ...}
  {categories}
    {if parent_id != "{my_cat_id}"}
      {!-- display the entry --}
      {title}
      {item_body}
    {/if}
  {/categories}
{/exp:channel:entries}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.