• I want to show the title of the page with no links to the draft pages.
    this is my code

    <?php
    wp_list_pages( array(
    ‘title_li’ => ”,
    ‘child_of’ => ‘4721’,
    ‘post_status’ => ‘publish,draft’
    ) );
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Your answer is in your code.

    <?php
    wp_list_pages( array(
    	'title_li' => '',
    	'child_of' => '4721',
    	'post_status' => 'publish' // remove draft
    ) );
    Thread Starter manucnx

    (@manucnx)

    i have to show draft page but without link

    Moderator bcworkz

    (@bcworkz)

    To selectively eliminate links on draft pages when using wp_list_pages(), you would need to specify a custom walker function as one of the arguments. This walker constructs the HTML for each page in the list, it can decide what HTML to use based on post_status.

    If the resulting list is flat (i.e. there are no grand children of 4721), you could abandon wp_list_pages() and get the page list with get_posts(), then loop through the results and only output link HTML for post_status publish. The presence of grandchild pages complicates the list enough that the walker solution is the better approach. Unless you don’t care to show the hierarchy of grandchildren.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_list_pages remove link to draft pages’ is closed to new replies.