So I have a template that is used for all pages in a section that has this script to create a menu based off children:

    if($post->ID = 142) {
        $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
    elseif($post->post_parent) {
        $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1"); 

    if ($children): ?>
            <li<?php if ( is_page($post->post_parent)) { echo ' class="current_page_item"'; } ?>>
                <a href="<?php echo get_permalink($post->post_parent) ?>">Overview</a>
            <?php echo $children; ?>
<?php endif; ?>

Problem is, when this menu is generated (which it does properly), it holds onto the parent page id of 142 and starts outputting content from custom fields as if it were that page. The interesting thing is that I'm calling a the_title further down the page and it's returning the correct page title. This problem persists even after wp_reset_query and wp_reset_postdata.

I just need the page to get its own ID back!

1 Answer 1


It looks like the problem is with your IF statement.

if($post->ID = 142)

should be if($post->ID == 142) (notice the 2 equals signs)

Otherwise you are just resetting the variable $post->ID to 142

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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