Support » Fixing WordPress » insert wp_list_pages in the pages without using exe-php (is there another way)

  • 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>";
    } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • 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().

    sounds like the API choice is the way to go

    Thanks

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘insert wp_list_pages in the pages without using exe-php (is there another way)’ is closed to new replies.