Trouble with parent and child conditional tag to show content

If it is about child post types* or taxonomies**:

// page/post/cpt parent check:
$post_object = get_queried_object();
// check if the page has a parent
if ( $post_object->post_parent )
    // do stuff

// cat/tax parent check:
$taxonomy_object = get_the_category( get_query_var('cat') );
// check if the cat/tag/tax has a parent:
if ( $taxonomy_object->parent )
    // do stuff

It could be that you have to check the if against 0 !== $post_/taxonomy_object, but it should work close to shown above.


*) Post types are the built in ones like post and page, or custom ones like custom post types.

**) Taxonomies are the built in ones like category (hierarchical), tags (non-hierarchical), post_format, etc, or your custom ones like custom taxonomies.