[wp-hackers] problem with $post->post_parent

Brian Fidler fidler.brian at gmail.com
Sun Mar 28 16:22:00 UTC 2010


I'm running the following code to set the gallery displayed based on the
page or the page's parent that a user is currently on.

However it is ignoring the $post->post_parent portion.

if ( is_page('paintings') || $post->post_parent == '912' ) {
    // the page is "About", or the parent of the page is "About"
    $myGallery='3';

} elseif ( is_page('loteria') || $post->post_parent == '25' ) {
    $myGallery='2';

} elseif ( is_page('prints') || $post->post_parent == '914' ) {
    $myGallery='18';

} elseif ( is_page('public-art') || $post->post_parent == '915' ) {
    $myGallery='18';

} elseif ( is_page('shop') || $post->post_parent == '29' ) {
    $myGallery='4';

} else {
    $myGallery='2'; // just in case we are at an unclassified page, perhaps
the home page
}

Any ideas what might be going wrong?

brian


More information about the wp-hackers mailing list