Support » Plugins » How to use categories in a CMS kind of way?

  • Resolved deko

    (@deko)


    This must have been asked before… if anyone can point me in the right direction that would be great.

    I want to have links in my header bar that will filter what appears in my main page by category.

    For example, I have about half a dozen links in the header bar that represent different categories, and the user clicks “Product Reviews” and all the posts in that category appear in the main page – same for all the other categories.

    There should also be a default category that shows only posts in, let’s say, “uncategorized” when the user first visists the page.

    Is this easy to do?

    Thanks in advance.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Do you mean you want links to each category archive in the header of your site? That should be very difficult at all, just use the right template tag:

    http://codex.wordpress.org/Template_Tags/wp_list_cats
    or
    http://codex.wordpress.org/Template_Tags/list_cats

    Thanks for the tip. Actually, I want to hard-code my categories in a nav bar (there are only four or five).

    It’s a very basic theme. No sidebar, no footer.

    So the appearance of the page stays pretty much the same, just the posts change as the user selects a category from the nav bar (header).

    So, in the simplest of terms, how do I show only the posts in a particular category?

    Secondly, how do I put that functionality behind a link in my header?

    Just put hyperlinks (<a href="yourblog.com/category/category-name">Category name</a>) straight into your header!

    If you’re not using “pretty” permalinks do this:

    <a href="yourblog.com/?cat=catID">Category Name</a>

    where catID is the number of the category you want to display.

    I tried this:

    <a href="http://www.mysite.com/category/Product Reviews">Product Reviews</a>

    but I get thrown in the 404 bucket.

    The composition of the link would lead me to belive there should be a ‘category’ directory in my site’s root… there is not…

    Try inserting one of the tags detailed in the codex pages I linked to above, and get the correct URLs from there.

    10-4. Thanks for you help!

    One way to do it is to click on a category link from the Manage admin page. This will sort posts by that category. Then you can identify the cat ID from your browser’s address bar and create your link like this:

    <a href="http://www.whatever.com/?cat=5">Product Reviews</a>

    If I get ambitious, I will use the list_cats() function to automatically create the links in my header bar.

    It’s not too hard, actually, plus if you switch to a pretty permalink structure, or change them, it will update the links automaticaly for you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to use categories in a CMS kind of way?’ is closed to new replies.