• Resolved csleh

    (@csleh)


    I have a few Pages set up, since the content is fairly static. Let’s say a Page has 1 category with multiple posts related to that topic. How can I associate categories to a certain page? For instance if I’m on page B, I need a link to posts 1, 2, 3 and 4 in the X category. Page C would need the same for posts in the Y category.
    Is there a way to associate a Page with a category? Or is there an if/then statement appropriate?

    Many thanks — I’ve been searching but think my phrasings must be not quite right to find answers.

Viewing 5 replies - 1 through 5 (of 5 total)
  • rudolf45

    (@rudolf45)

    I don’t know if something has been changed recently but normally Pages are not related to categories, in other words: Pages don’t have categories.

    Thread Starter csleh

    (@csleh)

    Perhaps I’m thinking all backwards —

    how might I have links to posts in 1 particular category, but only from 1 particular Page?

    Page A shows links (category apples) posts macintosh, gala, etc.

    Page B shows links (category baking) posts pies, cobblers, etc.

    Thread Starter csleh

    (@csleh)

    Is it possible to have the loop show something like this:

    -if page=id9, show posts in category2

    I’ve seen an if is=home statement — does that work for any page?

    (having a hard time making sense of the documentation. help greatly appreciated!)

    Thread Starter csleh

    (@csleh)

    I found this, seems to work.
    <?php if ( is_category(‘2’) ) : ?>

    <?php endif ; ?>

    I’m putting in this in for future reference — for myself and others who might search with similar terms.

    Thread Starter csleh

    (@csleh)

    darn something happened. here it is again:

    <?php if ( is_category('2') ) : ?>
    <ul>
    <?php
    $posts = get_posts('category=2');
    foreach($posts as $post) :
    ?>
    <li>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </li>
    <?php endforeach; ?>
    </ul>
    </li>
    <?php endif ; ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘link to category depending on current Page’ is closed to new replies.