• I create display list of parent and their child page use this code

    function my_list_child_pages() {
      if (is_page()) {
        global $post;
        $args = 'echo=0&sort_column=menu_order&title_li=';
        // Check whether page is parent/child page
        $page = ($post->post_parent) ? $post->post_parent : $post->ID;
        $parent   = wp_list_pages( $args.'&include='.$page );
        $children = wp_list_pages( $args.'&child_of='.$page );
        // If the current page has/is child page
        $list = ($children) ? '<ul class="disease-nav">'.$parent.$children.'</ul>' : '';
      }
      return $list;
      }
    
    add_shortcode('wpb_childpages', 'my_list_child_pages');

    Page A
    – Page A1
    – Page A2

    output:
    Page A
    Page A1
    Page A2

    I want to replace text output Page A without edit title from wp-admin. I want to result is
    Overview
    Page A1
    Page A2

    Anyone ever create function like that?

    Thanks

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I would use preg_replace() to replace whatever title exists in $parent with “Overview”. The title is always within the anchor tags. The regexp would break up the search string into 3 parts, the middle being the title text. The replacement would back reference the beginning and ending parts of the regexp with “Overview” in between. If you struggle with regexp (who doesn’t?), a “fiddle” tool for regexp is very useful. One example: http://www.regexr.com/

Viewing 1 replies (of 1 total)

The topic ‘Replace text from wp_list_pages’ is closed to new replies.