Forums

Forcing parent page for a post for current page highlighting? (2 posts)

  1. munkazuncle
    Member
    Posted 2 years ago #

    Hey all,

    I think this is an easy one, or hope it is. I'm stuck on a navigation progression, the normal of main section > blog posts and would like the nav section to still stay highlighted but have been stuck on that so far.

    In other words, I have sort of a secondary blog on a page, and when a post title is clicked, the nav "current_page" class goes away on the page title in the main nav (default) but I don't want it to...would look the post to look like it's "in" that page "section" especially since I have subpages I don't want to go away. Help! Thanks!

  2. munkazuncle
    Member
    Posted 2 years ago #

    btw - I'm using a pretty normal navigation loop for the main nav, and also for the subnav part...so just wondering if there's something I can do to set the variable for post_parent to sort of trick it?

    Main nav:

    <ul id="nav">
    <li <?php if (is_front_page()){echo 'class="current_page_item"';} ?> ><a href="<?php echo get_settings('home'); ?>">Home</a></li>
    <?php wp_list_pages('title_li=&sort_column=menu_order&'.$k_options['general']['com_page']);   ?>
    </ul>

    Subpage nav:

    <? //subpages navigation ?>
    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      if ($children) { ?>
      <ul id="sub-pages">
      <?php echo $children; ?>
      </ul>
      <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic