Support » Fixing WordPress » child_of not working

  • Resolved K1t


    I want to display the parent and child pages of a specified ID to show in a sidebar on single posts.

    My pages are using topmost ancestor and children, which is working great, but when it comes to viewing single posts, it is blank.

    I’ve tried using child_of where I can specify the parent page ID of the children I want to display, but it isn’t working (returns nothing).

    Can anyone PLEASE help me to get child pages (of a specified page ID) to display in a sidebar that is used on single post?

    Just to clarify, I DON’T want to display POSTS on my single.php sidebar. I DO want to display a specified PAGE and its children.

    Thanks for any help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    please post the code you are using for the sidebar;

    paste it into a and post the link to it here – HOWTO

    I have been playing with this in my single post sidebar:

    <?php wp_list_pages('child_of=66&title_li='); ?>

    But it’s not returning anything.

    On my pages, I am using list topmost ancestor and its immediate children. This is in my functions file:

    And this is being used to display the page list:

    List topmost ancestor and its immediate children is not working on my single posts.

    Any ideas appreciated. Thank you



    Forum Moderator

    the code looks ok;

    have you double-checked that 66 is a page Id of a parent page with children?

    a fixed programmed parent page Id should work with the ‘child_of’ parameter.

    obviously, on a single post, there is no automatic info for any parent pages.

    Oh my goodness, you are right! How embarrassing, I messed up my page IDs…. very stupid moment on my behalf, no wonder I couldn’t get it working!

    Thank you so much for challenging me on this. Sometimes I just overlook the simplest of solutions! Got it working now, thanks very much 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘child_of not working’ is closed to new replies.