• Resolved mzimmers

    (@mzimmers)


    Hi –

    I’ve read the docs on this, and I *think* I understand, but I want to be sure, because I’m basing some work on this.

    $thispage = $wp_query->post;

    Am I correct in my assumption that this is assigning the contents of a data structure (the current post) to a variable called $thispage?

    If I am correct, is there any documentation on the data structure for a post?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter mzimmers

    (@mzimmers)

    I did read that section. It’s helpful, but less than definitive. I have a section of code that isn’t behaving as I think it should. This excerpt is supposed to list a page’s parent (if one exists), the page itself, and any children of the page:

    $thispage = $wp_query->post;
    		if ($thispage->post_parent!=0)
            {
                wp_list_pages("title_li=Parent:&include=".$thispage->post_parent);
    			echo "this page's parent ID is " . $thispage->post_parent . $newline;
            }
    
    		wp_list_pages("title_li=ThisPage:&include=".$thispage->ID); 
    
    		echo "this page's ID is " . $thispage->ID . $newline;
    
            wp_list_pages("title_li=Children:&sort_column=menu_order&depth=2&child_of=".$thispage->ID); ?>

    But it’s not working right. I thought if could see the internals of the post data structure, I could de-bug this a little easier. Any other suggestions?

    Thread Starter mzimmers

    (@mzimmers)

    Anyway…if someone could explain why that works for top-level pages and sub-pages, but NOT for sub-sub-pages, I would appreciate it greatly.

    https://www.scopedin.com/wordpress

    Thread Starter mzimmers

    (@mzimmers)

    A little more information: when I follow a link to a sub-sub-Page, my “echo” tells me that the wp_query is returning the correct parent page ID, and the ID of the sub-sub-page is correct as well. Yet…wp_list_pages isn’t working for either.

    Any ideas? I could really use some help with this one.

    https://www.scopedin.com/wordpress

    Thanks.

    Thread Starter mzimmers

    (@mzimmers)

    OK…I think I’ll close this thread out and create a new topic that is hopefully more focused.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘what does this line of code do?’ is closed to new replies.