WordPress.org

Ready to get started?Download WordPress

Forums

Loading sidebar content based on is_page (2 posts)

  1. acmc
    Member
    Posted 6 years ago #

    I am trying to make a dynamic sidebar that loads based on the is_page function. Here is the code i placed:

    <?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?>

    <?php if (is_page('eadmin') ) { ?>
    <?php query_posts('category_ID=13&showposts=10'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h4><?php the_title(); ?></h4>
    <?php endwhile;
    } elseif (is_page('eproject') ) { ?>
    <?php query_posts('category_ID=3&showposts=10'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h4><?php the_title(); ?></h4>
    <?php endwhile;
    } else { ?>
    //whatever goes in here
    <?php } ?>

    The result is when i am on the eadmin or eproject page i get the else result above(?) i checked the page names in wp-admin and have tried both category_ID and category_name with no different result. What am I missing here?

  2. alanft
    Member
    Posted 6 years ago #

    you could instead go for widgets, and use one of the aside widgets to show titles of posts in your categories. you can use my http://wordpress.org/extend/plugins/widget-logic/ plugin to make those widgets condition on "is_page('eproject')" etc

Topic Closed

This topic has been closed to new replies.

About this Topic