WordPress.org

Forums

insert wp_list_pages in the pages without using exe-php (is there another way) (4 posts)

  1. jbencic
    Member
    Posted 7 years ago #

    i am trying to create a page which lists links for its sub-pages.

    currently i have created a new "pages" template and added the following code below. this all works fine

    i was wondering if it is possible to call the "wp_list_pages" function without having to use something like the exe-php plugins?
    this way i wouldn't have to create a new template.

    <?php if($post->post_parent) { // page is a child
    	echo "<ul>";
    	wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->post_parent);
    	echo "</ul>";
    }
    
    if(wp_list_pages("child_of=".$post->ID."&echo=0")) { // page has children
    	echo "<ul>";
    	wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->ID);
    	echo "</ul>";
    } ?>
  2. Adam Brown
    Member
    Posted 7 years ago #

    So you've found the first two options: exe-php and a page template. The third option would be to create a new plugin to do this, but I'm not sure that would be easier than the page template solution.

    Check out the Plugin API though if that's your thing. Hook into the "the_content" hook if is_page().

  3. jbencic
    Member
    Posted 7 years ago #

    sounds like the API choice is the way to go

    Thanks

  4. dlo
    Member
    Posted 7 years ago #

    I wrote a plugin that can be useful for that.
    You can even choose to display part of the text in addition to the title.
    You can find it there.

    Best regards

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.