Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Pretty simple question.

I have the 'blog' on my site set via 'reading' to be the page 'blog' located at mysite.com/blog. /blog is hierarchical, in that it has children.

I have a custom side bar that I include via a function in functions.php that does a simple include (ie: function get_right_sidebar() { include('sidebar_right.php) }; ). I list all pages and children via a simple function:

function get_post_top_ancestor_id(){
    global $post;

     if($post->post_parent){
        $ancestors = array_reverse(get_post_ancestors($post->ID));
        return $ancestors[0];
    }

     return $post->ID;
}

Followed by:

    <ul class="clearfix">
        <?php wp_list_pages( array('title_li'=>'','include'=>get_post_top_ancestor_id()) ); ?>
        <?php wp_list_pages( array('title_li'=>'','depth'=>1,'child_of'=>get_post_top_ancestor_id()) ); ?>
    </ul>

In the actual page template sidebar_right.php

Now, this navigation bar works completely fine, accept when I navigate to the base-level /blog. Nothing shows up in the sidebar.

After doing a global $post; print_r($post)in the sidebar_right.php I see that it is listing a post as the query, instead of page (and therefore is not getting the child pages to list in the sidebar).

I tried tossing in a wp_reset_query, but it did nothing.

Can anyone recommend what I should do in order to restore my navigation bar on my /blog section?

Thanks!

Tre

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

The problem when you set a 'page' as the blog roll through the back-end is that it automatically assigns the page as an 'archive'.

In order to solve the problem, I removed this option (ie: set blog roll to --Select--). I set the page to it's own custom template and made a custom query feed, so I could utilize wp_reset_query(). This then restored the functionality and my right sidebar navigation.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.