WordPress.org

Forums

[resolved] display pages AND custom fields on front page (7 posts)

  1. majestictreefrog
    Member
    Posted 4 years ago #

    I want to display the titles of certain pages (all pages that are children of a certain 'bios' page) AND with each title (the person's name) pull custom field information such as a url to their site, etc.

    It would be great if I could do this like a loop, but with pages.

  2. esmi
    Forum Moderator
    Posted 4 years ago #

  3. majestictreefrog
    Member
    Posted 4 years ago #

    Esmi,

    Thanks!

    Question though... it says it just returns 'array'.... array of what? page objects? I need to go through each page and print stuff (just like the wordpress loop) but I'm not sure how to access the data in the returned array.

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    From what I recall, it retains an object/array of all of the child pages - content and all. Try running the example shown on that page and you'll see exactly what is returned.

  5. majestictreefrog
    Member
    Posted 4 years ago #

    It did return objects/array... but of the 2 fake posts I made to the blog. Nothing page related.

    The messed up part is that both of the posts have "post_parent" at 0...

    for reference:

    $my_wp_query=new WP_Query();
    $all_wp_pages=$my_wp_query->query(array('post+type'=>'page'));//get all pages
    $student_bios=get_page_by_title('student-bios');//gets page as object
    $bios=get_page_children($student_bios->ID, $all_wp_pages);
    echo '<pre>'.print_r($bios,true).'</pre>';
  6. majestictreefrog
    Member
    Posted 4 years ago #

    output:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  7. majestictreefrog
    Member
    Posted 4 years ago #

    solved it using "get_pages()" with the 'child_of=' modifier.

    This works well. Also, I had to figure out what counts as 'title' by the get_page_by_title() method.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic