• Hi all,

    Been trying to find a solution to this with no luck.

    I have a custom post type of ‘projects’ with a custom taxonomy of ‘project-type’. I have 2 project types – ‘print’ and ‘web’.

    When displaying a single ‘projects’ post my sidebar needs to display the other posts in that taxonomy. For example: Project1 has a ‘project-type’ of ‘print’ so the sidebar should display all the posts in ‘print’.

    <div class='menuGroup'>
                        <?php query_posts( array( 'post_type' => 'projects', 'project-type' => 'print' ) );
                          if ( have_posts() ) : while ( have_posts() ) : the_post();
                        ?>
                        <div class='submenu'>
                                <div class="tiny latestthumbnail">
                                    <a href="<?php the_permalink() ?>">
                                        <?php the_post_thumbnail(); ?>
                                    </a>
                                </div>
                                <h5><?php the_title() ?></h5>
                        </div>
    
                        <?php endwhile; endif; wp_reset_query(); ?>
                    </div>

    Question is, how do I apply a <div class='submenu current_post'> to Project1’s item in the list when I’m on it’s single page?

    So I need my output to be something like this:

    <div class='menuGroup'>
                        <div class="submenu current_post">
                            <div class="tiny latestthumbnail">
                                <a href="#">
                                    <img src="../project1.jpg">                                </a>
                            </div>
                            <h5>Project1</h5>
                        </div>
                        <div class="submenu">
                            <div class="tiny latestthumbnail">
                                <a href="#">
                                    <img src="../project2.jpg">                                </a>
                            </div>
                            <h5>Project2</h5>
                        </div>
                        <div class="submenu">
                            <div class="tiny latestthumbnail">
                                <a href="#">
                                    <img src="../project3.jpg">                                </a>
                            </div>
                            <h5>Project3</h5>
                        </div>
                    </div>

    when I’m on Project1’s single page.

    Any ideas?

  • The topic ‘apply current class to single page custom post type navigation in sidebar’ is closed to new replies.