WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to use categories in a CMS kind of way? (11 posts)

  1. deko
    Member
    Posted 8 years ago #

    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.

  2. maerk
    Member
    Posted 8 years ago #

    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

  3. deko
    Member
    Posted 8 years ago #

    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).

  4. deko
    Member
    Posted 8 years ago #

    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?

  5. maerk
    Member
    Posted 8 years ago #

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

  6. pizzaman
    Member
    Posted 8 years ago #

    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.

  7. deko
    Member
    Posted 8 years ago #

    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...

  8. maerk
    Member
    Posted 8 years ago #

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

  9. deko
    Member
    Posted 8 years ago #

    10-4. Thanks for you help!

  10. deko
    Member
    Posted 8 years ago #

    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.

  11. maerk
    Member
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags