• After create-custom-taxonomies.
    If I use has_tag, I can’t call the new taxonomies.
    Can you tell me how I should use it?

    e.g
    <? Php.
    If (has_tag (array (‘OL’) {echo “<div class=’hdinfo’>oline</div>”;}.
    Else {echo “;}.
    ? >

Viewing 1 replies (of 1 total)
  • Anonymous User 14808221

    (@anonymized-14808221)

    This is how you need to use the WordPress Core function “has_tag”:
    has_tag( string|int|array $tag = '', int|object $post = null )

    I do not see this applied in your code example, however, I can also not assist here the usage of WordPress Core code and API.

    To display terms – created with Types – you can follow this great document on it:
    https://toolset.com/documentation/customizing-sites-using-php/creating-taxonomy-term-archives/

    For example, to display a list of terms to which a post belongs, you need to use the get_the_term_list() WordPress function. The following code outputs terms belonging to a “Spoken languages” taxonomy, attached to the post:
    echo get_the_term_list( $post->ID, 'spoken-language', '<p><strong>Spoken languages: </strong>', ', ', '</p>');

    It’s as well shown in the example templates (which the document mentions) in the Types Plugin.

    Please do not forget that Types, as it’s here, will not exist anymore starting end of this year.

Viewing 1 replies (of 1 total)

The topic ‘has_tag Function’ is closed to new replies.