WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] child_of not working (5 posts)

  1. K1t
    Member
    Posted 1 year ago #

    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.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    please post the code you are using for the sidebar;

    paste it into a http://pastebin.com/ and post the link to it here - HOWTO

  3. K1t
    Member
    Posted 1 year ago #

    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: http://pastebin.com/0T1AAtdW

    And this is being used to display the page list: http://pastebin.com/Fmnedd8P

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

    Any ideas appreciated. Thank you

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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.

  5. K1t
    Member
    Posted 1 year ago #

    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 :)

Topic Closed

This topic has been closed to new replies.

About this Topic