problem with custom single post templates and current_page_parent (3 posts)

  1. smrdo
    Posted 6 years ago #

    I have a main blog section on my site and a case studies section.
    Both contain psots filtered by their category (main_blog, or casestudy).

    I'm using he following solution in functions.php to allow sustom single post templates

    // allow single post page templates
    add_filter('single_template', create_function('$t', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ) return TEMPLATEPATH . "/single-{$cat->term_id}.php"; } return $t;' ));

    Hover if i click on a case study for example - to view it' single post, it used the correct template (in this case single-5.php) but the current_page_parent class from my main nav (using wp_page_menu) switches to the main blog section.

    Does anyone know of a way to force each single post template to set the correct 'current_page_parent' in the main menu?

    Many many thanks

  2. Ciprian Tepes
    Posted 6 years ago #

    Hi Mark,

    if you found a solution please share it :)

  3. smrdo
    Posted 5 years ago #

    hers what i did, If the single page is in a ceratin category i changed the class on the nav containing div and then used css to style accordingly

    <?php if (in_category('5')) { ?>
    	<div id="nav" class="caseStudyNav">
    	<?php }elseif (in_category('3')) { ?>
    	<div id="nav" class="blogNav">
    	<?php  } else { ?>
    	<div id="nav">

Topic Closed

This topic has been closed to new replies.

About this Topic