WordPress.org

Forums

How to 'Get Catagory Posts' on certain page (8 posts)

  1. adamgatenby
    Member
    Posted 7 years ago #

    Hello,

    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?

    Thanks,

  2. syncbox
    Member
    Posted 7 years ago #

    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

    2007
    2006
    2005
    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.

    HTH

  3. abovethelies
    Member
    Posted 7 years ago #

    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.

  4. moshu
    Member
    Posted 7 years ago #

    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.
    More:
    Category_Templates and Template_Hierarchy

  5. adamgatenby
    Member
    Posted 7 years ago #

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

  6. moshu
    Member
    Posted 7 years ago #

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

  7. adamgatenby
    Member
    Posted 7 years ago #

    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.

  8. moshu
    Member
    Posted 7 years ago #

    Once again and for the last time: YOU DON'T NEED ANY PAGES for that, don't complicate your life!!!
    http://www.transycan.net/blogtest/2007/07/26/pages-and-categories/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.