• Resolved mastron

    (@mastron)


    Hi There

    I have a hard question, at least to me. I can sove it on a large way but I like it to be small.

    I have 10 categories and 10 pages.

    What i would like to happen is that the page sport only shows posts in the category sport. I know I can make 10 page templates with only the category post in it, but I was wondering if it is posible in one page.

    I was thinking of something like:

    if page title is sports show category=1

    else

    if page title is news show category=2

    else

    etc.

    But then in PHP .. which I am not good at.

    The website I am making is:
    https://www.kanaalhelmond.nl/web

    Thanks in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Wrong approach. Do NOT use Pages – they are not for displaying posts.

    You need Category_Templates.

    Thread Starter mastron

    (@mastron)

    I need to use pages. My menu is built up on the pages I made, so a category list does not work for me.

    If I use a category template I have to make 10 category pages and I like to use one page.

    Is it posible and how?

    I still think it is easier to change one line of code in the menu than changing how WordPress works… and if you are not styling them differently you don’t even need Category Templates (or only one).

    Anyway, if you want to do it in your way – you are welcome. Just don’t ask for help if you know better.

    Thread Starter mastron

    (@mastron)

    I understand what you are saying. I would prefer to do it that way and use category selection in my menu. But the thing is that I am using a plugin to show my pages:

    https://goudendouche.com/dropdown-menu-plugin/

    This plugin shows the pages and not the categories, please have a look at the site that I am working on:

    https://www.kanaalhelmond.nl/web

    Thread Starter mastron

    (@mastron)

    Got it:

    <?php

    if (is_page(‘Nieuws’)) {
    query_posts(‘cat=4’);

    } else if

    (is_page(‘Lokaal’)) {
    query_posts(‘cat=5’);

    } else if

    (is_page(‘Gemeente’)) {
    query_posts(‘cat=6’);

    } else if

    (is_page(‘Sport’)) {
    query_posts(‘cat=7’);

    } else if

    (is_page(‘Cultuur’)) {
    query_posts(‘cat=8’);

    } else {
    query_posts(‘cat=’ . $events_cat . ‘&paged=’ . $paged);
    }
    ?>

    Does that code go into the page.php template? and/or index.php?

    Nevermind… Got it! Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Link category to page’ is closed to new replies.