2014-02-17 22:01



I've downloaded a couple of plugins already, but none satisfy what I need: I need a widget to display the child pages of a specific parent page (and to customize it via CSS to include an icon on each 'li' and a certain background-color, borders.). I've also downloaded a plugin which enabled me to add categories to each page, thinking that then I could use a widget that displays specific pages titles from a determined category (and in that way solve the issue), but I haven't found one to do so.

Should I edit the default pages widget (which actually lets me sort via page ID, Page Title and Page order), to enable it to also sort by pages from a speficic category? I don't know much PHP to do so.

I though of using the default page widget and exclude every page ID but the ones I need to appear, but then when some other person makes a new page, it will be displayed by the widget, and that should not happen as only the child themes of a specific parent page should be displayed.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dqalnwuci494308 dqalnwuci494308 7年前

    This is the way to do it....taken from Wordpress Codex...

    $descendants = get_pages(array('child_of' => $ancestor_id));
    $incl = "";
    foreach ($descendants as $page) {
    if (($page->post_parent == $ancestor_id) ||
       ($page->post_parent == $post->post_parent) ||
       ($page->post_parent == $post->ID))
      $incl .= $page->ID . ",";
    <?php wp_list_pages(array("child_of" => $ancestor_id, "include" => $incl, "link_before" =>       "", "title_li" => "", "sort_column" => "menu_order"));?>
    点赞 评论 复制链接分享