• Resolved sincewelastspoke

    (@sincewelastspoke)


    Hi,

    I have a site and want to show a message in the sidebar if a page id equals 5 or if the parent page id equals 5?

    Kinda like if is_page('5') { echo 'hello'; } but also have the parent id of the page taken into consideration.

    What is the best way to do this?

Viewing 1 replies (of 1 total)
  • Thread Starter sincewelastspoke

    (@sincewelastspoke)

    <?php
    			global $wp_query;
    
    			if( empty($wp_query->post->post_parent) ) {
    			$parent = $wp_query->post->ID;
    			} else {
    			$parent = $wp_query->post->post_parent;
    			}
    			echo $parent;
    			wp_list_pages("title_li=<h2>Subpages</h2>&child_of=$parent");
    		?>

    RESOLVED….Sorta

Viewing 1 replies (of 1 total)
  • The topic ‘If is_page or is_parent_of ?’ is closed to new replies.