Check for the type of the page:
function get_author_bio ($content=""){
if ( ! is_single() ) // not a blog post, stop immediately
{
return $content;
}
global $post; // continue with regular work
The easiest way to learn these check functions is a look at the function get_body_class()
. Here are the most important:
is_rtl()
is_front_page()
is_home()
is_archive()
is_date()
is_search()
is_paged()
is_attachment()
is_404()
is_single()
is_page()
is_singular() // same as is_page() and is_single()
is_attachment()
is_archive()
is_post_type_archive()
is_author()
is_category()
is_tag()
is_tax()
is_user_logged_in()
is_admin_bar_showing()
You can even combine them:
// search results, not the first page
if ( is_search() and is_paged() )
// attachment and user has probably a profile
if ( is_attachment() and is_user_logged_in() )
Some of these functions accept parameters to restrict the result:
// contact page only
if ( is_page( 'contact' ) )
// this post was written by the tooth fairy
if ( is_author( 'tooth-fairy' ) )