/ Published in: PHP

This makes template code that applies to children of a particular page much more readable, especially if you can use a page path instead of an ID: `if ( is_child_of( 'topic/subtopic' ) ) :`.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function is_child_of( $page_id, $potential_child_id = '' ) { $is_child = false; $page = get_page_by_path( $page_id ); } $potential_child_id = get_the_ID(); } $potential_child = get_page( $potential_child_id ); } return $is_child; }
Comments
