check the parent page in wordpress theme

Hay all…
Today, I am going to show how to identify the parent page in wordpress. It’s very easy to do. Just write a 3 line code in page.php file in wordpress.

<?php
if(get_pages(array(‘child_of’=>’post_ID’)) || $post->post->parent){
echo “This is the parent page”;
}else{
echo “This is not a parent page”;
}
?>

Save your file and check the page.

Advertisements

2 Comments

  1. Wonderful beat ! I would like to apprentice while you
    amend your web site, how could i subscribe for a blog website?
    The account helped me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear concept

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s