in_webcomic_character

Summary:

A shortcut function for WordPress’ own is_object_in_term(). Checks if a post has the specified character term.

Tag and base function call:

function in_webcomic_character( $terms = false, $id = false ) {
    global $webcomic; return $webcomic->in_webcomic_term( 'webcomic_character', $terms, $id );
}

Examples:

<?php
if ( in_webcomic_character( 47 ) )
    echo 'Yup. A character with ID=47 is in the current webcomic.';
?>

 

<?php
if ( in_webcomic_character( array( 'the_banana_man', 'a_large_salmon' ) ) )
    echo 'Yup. A character with the slug "the_banana_man" and/or "a_large_salmon" is in the current webcomic.';
?>

 

<?php
if ( in_webcomic_character( 'The Banana Man' ) )
    echo 'Yup. A character with the name "The Banana Man" is in the current webcomic.';
?>

 

<?php
if ( in_webcomic_character( 47, 3 ) )
    echo 'Yup. The character with ID=47 is in the webcomic post with ID=3.';
?>

Arguments

  • terms (str|int|array) technically optional
    The terms (characters) to search for.
    default: false; can be the character slug, name, or ID or an array of such.
  • id (int) optional
    The ID of the post you wish to check. If false, uses current post ID.
    default: false; can be any integer.
Share
Facebook Twitter Digg Stumble Delicous Email