• hi
    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
    Mark

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Mark,

    if you found a solution please share it ??

    Thread Starter smrdo

    (@smrdo)

    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">

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘problem with custom single post templates and current_page_parent’ is closed to new replies.