Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6227981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:18:39+00:00 2026-05-24T09:18:39+00:00

I am currently doing the following in my wordpress theme, <?php $pagelist = wp_list_pages(

  • 0

I am currently doing the following in my wordpress theme,

    <?php

$pagelist = wp_list_pages( array( 
    'include' => '154, 136', 
    'title_li' => '', 
    'sort_column' => 'ID', 
    'sort_order' => 'DESC', 
    'depth' => '0',
    'echo' => false
));

if($post->post_type == "casestudy") {
    $args = array( 'post_type' => 'casestudy');
    $case_studies = new WP_Query( $args );
    $casestudylist = "";
    foreach ($case_studies->posts as $k => $v) {
        $active = ""; 
        if($v->post_status == "publish") {
            if($v->ID == $post->ID)
            {
                $active = "current_page";
            }
            $casestudylist .= "<li class='subnav ".$active."'><a href=".$v->guid.">". substr($v->post_title, 0, strpos($v->post_title, ':')) ."</a></li>";
        }
    }
}


$testimonials = wp_list_pages( array( 
    'include' => '318', 
    'title_li' => '', 
    'sort_column' => 'ID', 
    'sort_order' => 'DESC', 
    'depth' => '1',
    'echo' => false
));
//die(print_r($casestudylist));

$concatenatedlist = $pagelist . $casestudylist . $testimonials;

?>



<aside class="secondary">
    <nav>
        <ul>
            <?php echo $concatenatedlist; ?>
        </ul>
    </nav>
</aside>

This builds a navigation, and gives the impression that a page has some children that are built with custom post types. The problem is that if I’m looking at a post from the $casestudylist I need to somehow also add an active class onto the first link that comes from $pagelist, even though the two are unrelated. I don’t mind if it is a jQuery solution. Basically, if an element in my casestudylist is active, I need to have the case study link marked as active also.

Here is the HTML the PHP creates.

    <aside class="secondary">
    <nav>
        <ul>
                <li class="page_item page-item-154">
                      <a href="/clients">Clients</a>
                    </li>
                    <li class="page_item page-item-136">
                        <a href="/case-study">Case Study</a
                    </li>
                    <li class="subnav current_page">
                        <a href="/?post_type=casestudy&amp;p=161">Brenntag</a>
                    </li>
                    <li class="subnav ">
                         <a href="/?post_type=casestudy&amp;p=104"></a>
                    </li>
                    <li class="subnav ">
                         <a href="?post_type=casestudy&amp;p=65"></a>
                    </li>
                    <li class="page_item page-item-318">
                        <a href="/testimonials">Testimonials</a>
                    </li>
        </ul>
    </nav>
</aside>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:18:39+00:00Added an answer on May 24, 2026 at 9:18 am

    To do it in jQuery you could say:

    if($('li.subnav.current_page').length>0) {
        $('li.page-item-136').addClass('current_page');
    }
    

    But hard-coding the post ID isn’t very robust, nor is relying on jQuery to apply a style that WP should be serving.

    There are a few ideas here worth looking into, but my gut reaction is to do one of the following:

    • Substitute pages with parent-child relationships for the page and custom posts
    • Create a custom taxonomy to envelop all the pages involved, and alter your theme to display it.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently doing the following to use typed datasets in vs2008: Right click on
I'm currently doing the following as part of my iPhone application NSArray *paths =
I am currently doing a code review and the following code made me jump.
I'm currently doing integration testing on a database and I have the following sql
I am currently doing the following in my code avoid the issue of obscured
I'm currently doing the following to clear out an NSMutableDictionary [myDictionary release]; myDictionary =
I'm currently doing the following: timestamp = Time.new.to_time.to_i.to_s Is there a function in rails
I have a form in MVC 3. Currently I am doing the following to
I'm currently doing the following to create and execute a simple python calculation, using
I am currently doing the following to select posts from a custom post-type, query_posts('post_type=slideshow')

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.