WordPress.org

Ready to get started?Download WordPress

Forums

Page list from current loop? (not from default) (1 post)

  1. Zambrano Sergio
    Member
    Posted 2 years ago #

    I'm using a shortcode to pull a list of child-pages placed in a post, but that only works when the shortcode is called by the main loop.

    I'm calling that page (where the shortcode is) from the index.php so home page features that page, and the list of pages returned by this shortcode (which just uses wp_list_pages) lists ALL THE PAGES in the blog.

    So it's obviously taking the pages from the page I'm looking at, not the pages the shortcode is in, and the way WP knows what page I'm looking at is by the main query, I think.

    How do I do the list of pages to show the child pages of the current loop it's in? i.e. a secondary loop.

    I can't specify the id of the parent page where the child pages should be taken from, since the shortcode MUST remain the same across a multi-site installation, and I can't ensure all the parent pages will have the same id assigned. So, I'd like to keep the magic which makes the list in the post, so I can export it with the rest of the posts to another site (in the same network) so modifying the php code of the page's template is not an option. Modifying the functions.php is a possibility.

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by Zambrano Sergio
  • This topic is not resolved
  • WordPress version: 3.2.1