user1820262
user1820262

Reputation:

Wordpress, is_page parent & child

Is there a way to create an is_page statement which targets the parent page & also all of the child pages? This is my code so far.. and only works on the parent page.

<?php if( is_page( array( 'view-by-collections') )   ) { ?> 
** MY CODE **
<?php } ?>

Upvotes: 0

Views: 3087

Answers (1)

Ovidiu Iacomi
Ovidiu Iacomi

Reputation: 776

I suggest you use the ID of the page in question and try something like this:

<?php if (is_page(ID_OF_VIEW_BY_COLLECTIONS) || $post->post_parent == ID_OF_VIEW_BY_COLLECTIONS) { ?>
** Your Code **
<?php } ?>

Upvotes: 2

Related Questions