WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] How to show only one categories posts on page? (9 posts)

  1. sealyspeak
    Member
    Posted 2 years ago #

    Hi All,

    I am trying to create a category loop based on the code I have paste binned http://pastebin.com/ent6Jq9B , which I can control so if I make a News page, it ONLY displays news posts. If I make a Books page, it will only display a book post, etc...

    I am using Mystique theme, latest updated version extended and I am not getting anywhere fast.

    What I need to do is create a category-news.php as a template for my page, a category-book.php template, etc... but using the code attached from Mystique. I just can't figure how to do t?

    I did try "Pages link to" plugin, which was NEARLY perfect. It just didn't show in the navigation bar that I was actual on that page.

    I am new to this, so any code examples based on my code would be great!

    Cheers

  2. peredur
    Member
    Posted 2 years ago #

    The usual way of doing this is via Category lists. That way, you don't have to mess with the code.

    See Urban Words for an example of a site that uses several category lists (e.g. Residencies, Consultancy, Blog).

    HTH

    PAE

  3. sealyspeak
    Member
    Posted 2 years ago #

    I posted the wrong code in my first post! Sorry, was a long day yesterday. Below is correct:

    http://pastebin.com/vC5kUTEr

    Thanks peredur, I know about creating category lists, it's just trying to get 4 pages (within Mystique theme) that will display ONLY the category I want them to. The pages need to sit in the main navigation alongside normal pages. I did try "Pages link to" plugin, which was NEARLY perfect. It just didn't show in the navigation bar that I was actual on that page.

    I am pretty sure I need to write a custom category.php for each page template. Can anyone help?

    I am pretty new to this...

  4. peredur
    Member
    Posted 2 years ago #

    Category lists do only show the posts in that category. You just have to remember to allocate the category when you create the post. The urbanwords site I linked to before has categories for Consultancy and Residencies, for example, on which are listed just those things. So if you wanted to have a list of posts on the subject of 'the 1950s', you just create a category of (say) '1950s' and allocate it to all your posts that deal with that period. Then, in your main menu (which you will have to create and allocate as the site's main navigation menu as explained in this article) you simply add the category lists to the menu so your user can access them.

    I'm not sure what you mean about separate domains. A domain means something quite specific to me.

    Of course this means that you create posts and not pages. Only posts have categories. But this is the usual way that it's done. The idea is that you take advantage of WordPress' built-in functionality rather than trying to code it all up yourself.

    HTH

    PAE

  5. digitalnature
    Member
    Posted 2 years ago #

    Why not just create a menu item that links to the desired category page?
    Or am I missing something here?

  6. peredur
    Member
    Posted 2 years ago #

    See further up the thread. It was my first suggestion.

    cheers

    PAE

  7. sealyspeak
    Member
    Posted 2 years ago #

    Many thanks to you all for your help, I was by all accounts trying to reinvent the wheel with this post question. I was attempting to write specific category templates that did not need to be written as WordPress (and peredur & digitalnature) and the fantastic theme do this for you!

    Ahh! The problem was I was working through some tutorials about calling in specific categories and tried to apply them to Mystique. What a waste of time.

    I have a new post about Mystique, but this time it is a real one...

  8. phalancs
    Member
    Posted 1 year ago #

    Having the same problem here but you won't share your insight with us??

    Hmm

    Blog is this: http://www.lolr.de

  9. Andrew
    Forum Moderator
    Posted 1 year ago #

    Create your own thread if you're having the same problem. This discussion ended 11 months ago.

Topic Closed

This topic has been closed to new replies.

About this Topic