• Is there a way to use this code without showing the parent title?

    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      if ($children) { ?>
    
    <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>

    [Please post code snippets between backticks or use the code button.]

Viewing 4 replies - 1 through 4 (of 4 total)
  • That code snippet doesn’t output the parent’s title – just the list of children.

    Thread Starter louissoriano

    (@louissoriano)

    Thanks. Actually Below is what I am trying to achieve:

    I’m having some problem with my menu and was hoping if someone could help me? I’m kinda new to wordpress and still don’t know how to actually edit php pages.

    I have a menu:

    PARENT
    PARENT
    PARENT
    – Child-1
    — grandchild(1)
    — grandchild(1)
    – Child-2
    — grandchild(2)
    — grandchild(2)
    PARENT

    Would it be possible to show just the grandchild(1) of Child-1 if you are inside Child-1? And I was hoping to show all the grandchild(1) listing if you are inside grandchild(1) only.

    And if you are inside Child-2 the menu would just list grandchild(2)?

    The code I got from this site is this:

    <?php
    if($post->post_parent)
    $children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″);
    else
    $children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″);
    if ($children) { ?>

      <?php echo $children; ?>

    <?php } ?>

    But the code above is also showing the Child-1 and Child-2 title. Is it possible to not show the title of Child-1 and Child-2? Thank you very much for your time and reply.

    Here is my site:
    https://www.dentalmarketing.com.au/brighter-smile-dental/wp/?page_id=25

    maybe you can make use of some of this code:
    https://pastebin.com/RdjQCsMp

    it is written as a function, but you could simply use the code in your template.

    Thread Starter louissoriano

    (@louissoriano)

    Thanks so much. Unfortunately I’m getting some fatal errors when I inserted the code.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘List subpages even if on a subpage without listing the parent title’ is closed to new replies.