is_singular
only accepts one argument- post type. It’s only for checking if a post is of a certain type(s), not a specific post of that type. Check $post->ID
instead-
if(is_singular('guides' )&&($post->post_parent==$pid||$post->ID==$pid))
I would also consider using get_queried_object()
and/or get_queried_object_id()
rather than use the global $post
.