• Hey all,

    On my site I have a template that is used by one page, and a single-template for posts related to that page

    • page-staff (used as an index to display all staff)
    • single-people (the post type is called people)

    However, when I am displaying a staff members profile (using ‘single-people’), my main Index is marked as current_page_parent, and this is screwing my tabs up. Is there any way to tell WP that I want another page to be the parent, so that I don’t have to do lots of re-writing to sort tab colouring out?

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The parent/child relationship isn’t determined by how you display the pages on the front end. It is determined by how you set the ‘Parent’ value when you create/edit the page.

    Thread Starter David Gard

    (@duck_boy)

    If that’s the case, then I would suggest that there is an error in the wp_list_pages() function.

    I have a page called ‘Marketing’, and when it’s child ‘Referrals’ is active apparently my index is the current_post_parent.

    Here is the code from ‘wp-includes\post-template.php’ –

    if ( !empty($current_page) ) {
    	$_current_page = get_page( $current_page );
    	_get_post_ancestors($_current_page);
    	if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) )
    		$css_class[] = 'current_page_ancestor';
    	if ( $page->ID == $current_page )
    		$css_class[] = 'current_page_item';
    	elseif ( $_current_page && $page->ID == $_current_page->post_parent )
    		$css_class[] = 'current_page_parent';
    } elseif ( $page->ID == get_option('page_for_posts') ) {
    	$css_class[] = 'current_page_parent';
    }

    I’ve done some tests and it is using the final elseif clause to mark my index as the current_post_paren, so from the looks of it this piece of code thinks that there is no $current_page, even though it is marking ‘Referrals’ as the current page.

    Thansks.

    If that’s the case, then I would suggest that there is an error in the wp_list_pages() function.

    That might be. I like WordPress, but there are some functions I consider buggy. That particular one I don’t use much so I’m not sure about it. Still, certainly possible.

    Are ‘Marketing’ and ‘Referrals’ actual pages and not custom post types?

    Thread Starter David Gard

    (@duck_boy)

    Are ‘Marketing’ and ‘Referrals’ actual pages and not custom post types?

    Yeah, both pages, with ‘Marketing’ being the parent.

    And I’m thinking to be honest I may just set a global on the page that loads and set the active class of the page then, at least that way I’ll know it’s definatly gonna be right!

    Thanks.

    Dont know if this will help, but I was having a similar issue.

    I was running into this problem with pages I created calling custom loop templates. WordPress was only assigning “current_page_parent” to my default news page and not my custom news pages. The problem was, I wasn’t resetting my queries.

    The fix for me was to call wp_reset_query() after each one of my custom loops.

    Thread Starter David Gard

    (@duck_boy)

    Thanks Jamie, I’ll give that a try when I get chance.

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP selecting wrong page as 'current_page_parent'’ is closed to new replies.