• Hi,
    On this page: https://cornhill.org/cornhillbeta/living-here/the-gazette/, The Gazette Link in the sidebar is not changing to the ‘current_page_item’ style I have set up.

    The code on the template page is:`<?php
    if (is_page(’14’)) {
    query_posts(‘cat=3748’);
    }

    if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>`

    and the code on the sidebar page is:

    <ul>
     <li<?php if ( is_page(14) || is_page(48) || is_page(52) || is_page(56) || is_page(41) || is_page(54) ) { echo ' class="current_page_item"'; } ?>></li>
     <?php wp_list_pages('include=14,48,52,56,41,54&title_li=<h2 class="livingtitle">' . __('Living Here') . '</h2>' ); ?>
    </ul>

    Can anyone tell me what I did wrong?

    Thank you very much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • the query in the main part is probably changing the query string, and therefore the if statement in the sidebar is not checking the right thing.

    try to add a wp_reset_query(); after the endif of your loop.

    Thread Starter Daniella

    (@ellaj)

    Worked. Thank you SO much!

    Thread Starter Daniella

    (@ellaj)

    Hi again,
    Well, it worked for highlighting the menu option but now the other links on the page (https://cornhill.org/cornhillbeta/living-here/links/) have the post title for the Gazette page. That wasn’t supposed to happen.
    The code:`<div id=”post-entry”>

    <?php
    if (is_page(’14’)) {
    query_posts(‘cat=3748’);
    }

    if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>
    <div class=”postheader”>
    <div class=”postthumb”> <a href=”<?php bp_group_permalink() ?>” title=”<?php bp_group_name() ?>”>
    <img src=”https://cornhill.org/cornhillbeta/wp-content/themes/bp-community/_inc/images/gazette-blog.jpg&#8221; alt=”Gazette” />
    </a></div>
    <div class=”inner”>
    <div class=”top”>
    <div class=”postdate”><div class=”leftdate”><?php the_time(‘j’) ?></div><div class=”rightdate”><div class=”rightmonth”><?php the_time(‘F’) ?></div><div class=”rightyear”><?php the_time(‘Y’) ?></div></div></div>
    <h1 class=”posttitle”><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a></h1>
    <div class=”clear”></div>
    </div><!–Top–>

    <div class=”bottom”>
    <div class=”inner”>
    Posted By: <?php the_author_posts_link(); ?>  |  <?php single_cat_title(); ?>  |  <?php comments_number(‘0 comments’,’1 comment’,’% comments’); ?>
    <div class=”clear”></div>

    <div class=”clear”></div>
    </div>
    </div>
    </div>
    </div>

    <div <?php if(function_exists(“post_class”)) : ?><?php post_class(); ?><?php else: ?>class=”post”<?php endif; ?> id=”post-<?php the_ID(); ?>”>

    <div class=”post-content”>
    <?php the_content(); ?>

    <?php wp_link_pages(array(‘before’ => ‘<p><strong>Pages:</strong> ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>
    </div>

    </div>

    <?php endwhile; ?>

    <?php else: ?>

    <?php load_template (TEMPLATEPATH . ‘/result.php’); ?>

    <?php endif; ?>
    <?php wp_reset_query(); ?>
    <div class=”clear”></div>
    </div>`

    Thank you so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem with 'current page item'’ is closed to new replies.