WordPress.org

Ready to get started?Download WordPress

Forums

how come this does not work "!_is_404" (2 posts)

  1. carlos-amigos
    Member
    Posted 6 years ago #

    I have this code on my sidebar and instead of NOT outputting the code on a 404 page is outputs all children pages throughout my site...how can I stop this? -- Is there another way of doing "NOT EQUAL TO 404, or this !is_404"

    if( is_page() && !is_404() && $post->post_parent)
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0"); else
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");

    Thanks
    Carl

  2. ceejayoz
    Member
    Posted 6 years ago #

    Your else statement is still being executed. You need something like this:

    if(!is_404()) {
    if(is_page() && $post->post_parent) {
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
    } else {
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    }
    }

Topic Closed

This topic has been closed to new replies.

About this Topic