Forums

getting many subject pages to talk to same template (5 posts)

  1. aeroflight
    Member
    Posted 2 years ago #

    I am building a website which includes pages on each country of the world, with 5-6 posts about topics such as geography, background history etc on each, plus links to sub-pages.

    I would like a single 'country main page' template that recognises what country the page is and calls the appropriate posts.

    if country-geography is posts category 9

    cat_ID=9 and tag=malta, or tag=geography+malta should find the post required. I can put malta in a custom field on the page, but how can the php template convert the custom field variable into a category or tag to retrieve posts?

    Thanks for any help!

    John

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    The Page of Posts example in the Pages article would be the place to start...you'd need to expand the logic to support your tags.

  3. Jonas Grumby
    Member
    Posted 2 years ago #

    Check out the docs on Page Templates. There's an example posted about how to use a page template to make a page that displays the posts within a given category. It may be fairly simple to adapt to make it display by tag, but you may already have the content assigned to categories.

    http://codex.wordpress.org/Pages#A_Page_of_Posts

    I have used this example and it works.

  4. aeroflight
    Member
    Posted 2 years ago #

    Er yes, that would work, but would require me to include about 200 $cat= statements in the template to allow for one for each country.

    Is there a way of doing it semi-automatically, or with less typing at any rate?

  5. Jonas Grumby
    Member
    Posted 2 years ago #

    Use the country names as category names and set the category list to be a drop-down like on this site:

    http://oldcarnetwork.com/

Topic Closed

This topic has been closed to new replies.

About this Topic