• Hello all,

    I am trying to customize this plugin: https://www.tastycornbread.com/category-plugin/

    I want to be able to exclude categories from custom templates in my wordpress site. This plugin is great, but does not have this functionality. It currently allows you to exclude from the front page, search results, archives, etc. How do I add a custom page to that list. You can install the plugin to see what I am talking about.

    Thanks everyone.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    1. Bumping 3 times in 2 minutes is not good. Don’t ever do it again.

    2. I want to be able to exclude categories from custom templates… If these templates are custom, why don’t you simply add a call to query_posts() on them which excludes the categories you don’t want? No need for a plugin.

    Thread Starter robmcfadden

    (@robmcfadden)

    I tried that. This is currently what is in there:

    query_posts(‘orderby=date&order=DESC’)

    It shows the most recent posts, but when I add cat=3 to that nothing changes. See, I want to show the most recent posts from all categories on the main index, but when someone goes to one of the category pages, I would like to show the most recent posts from that category. Thanks for your help. Any other ideas?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Ahh.

    Your problem is that your query_posts() call is ignoring the previous settings and creating a new query.

    Think of it like this. query_posts() is a reset switch. When you use it, you’re overriding the default query (generated automatically based on things like what page the viewer is looking at) with your own settings. Since you did not specify a category, you get them all.

    Now, when somebody looks at a specific category page, they have specified a category. However, your query_posts call overrides their choice, you’re demanding all categories by the simple act of not specifying one.

    What you need to do is to override only SOME of the user/viewer choices, not all of them.

    So, short version:

    Instead of this:
    query_posts('orderby=date&order=DESC')

    Use this:
    query_posts($query_string . '&orderby=date&order=DESC')

    Pretty simple, really.

    Thread Starter robmcfadden

    (@robmcfadden)

    Thanks, I will try this and get back to you. Thanks for your help, really.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Excluding Categories from Custom Templates’ is closed to new replies.