Support » How-To and Troubleshooting » How to ‘Get Catagory Posts’ on certain page

How to ‘Get Catagory Posts’ on certain page

  • adamgatenby



    I am developing a site for a school. I want to have pages for every year. IE. year 1, 2 etc…. So when i teacher posts something on to the website, and tick the catagory boxes which are relevant, that post then displays on that page.

    I have played about with templates and the get posts etc, but cant really seem to get it to work.

    Is there any easy way to do this?


Viewing 7 replies - 1 through 7 (of 7 total)
  • syncbox


    Um, couldn’t you use categories for the years instead of Pages?

    When a teacher posts, they simply choose which years their post(s) are relevant for… posts may be categorized under multiple categories.

    The layout for the page would use category.php assuming you have one or index.php if you don’t.

    Let’s say you list all the categories (which results in a list of years, as in

    2004 (etc)

    clicking that link would get posts from that category only, using the category.php or index.php file (you could create custom category-x.php files for each category id as well)

    a URL to the site in question would help. I think that you need to use categories, not Pages. WordPress Pages do not display posts.




    Edit the Archive Pages. Instead of the title being Archive %category% remove the text Archive. Then when they choose the 2007 category it will post to that ‘page’ and all posts in the category 2007 will be there.

    Forget the “Archives Pages” mentioned above – that’s wrong advice.

    Save your archive.php template as category.php (or if you want a different look for each of them – as category-xx.php, where xx = cat ID); edit them and they will do exactly waht you want.
    Category_Templates and Template_Hierarchy



    Thanks moshu. Had a look through the pages you had linked too, and getting to understand it a little more now. Could you give an example of code which would get say, the title, content of the last 5 posts in category 13 say?

    Just to give me a better understanding. Not really so up on my php etc.

    Thanks in advance!!

    I don’t get it. You don’t need any special code – WP does it all for you!

    If you assign a post to a category then clicking on the category name on the “frontend” it will take you to a view where only posts from that category are displayed.

    You are overcomplicating it…



    Thanks for the reply moshu.

    In that case, how can i link or say, display the category posts on a certain page. I know the category pages are there, but don’t know how to link to them. My menu is based on what pages i have on the site.

    Hope this makes sense.

    Once again and for the last time: YOU DON’T NEED ANY PAGES for that, don’t complicate your life!!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to ‘Get Catagory Posts’ on certain page’ is closed to new replies.
Skip to toolbar