[Resolved] generate_logo_href based on tags or categories

Home Forums Support [Resolved] generate_logo_href based on tags or categories

Home Forums Support generate_logo_href based on tags or categories

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1607022
    Matej

    Hello,

    Is it possible to have the logo link to different pages based on tags or categories?

    Something like:

    if (tag) {
    return “custom-url”
    } else {
    return “home-page”
    }

    Thank you very much!

    #1607255
    Ying
    Staff
    Customer Support

    Hi Matej,

    Try this filter:

    add_filter( 'generate_logo_href', function( $url ) {
        if ( is_tag ( 'the specifc tag' ) ) {
            return 'https://NEW-URL-HERE';
        }
    
        return $url;
    } );

    Let me know 🙂

    #1607613
    Matej

    Hello Ying,

    thanks for your answer. Unfortunately, it doesn’t work for me.

    Id doesn’t recognize the tag.

    Thanks!

    #1607667
    Elvin
    Staff
    Customer Support

    Hi,

    thanks for your answer. Unfortunately, it doesn’t work for me.

    Id doesn’t recognize the tag.

    Can you try changing is_tag with has_tag?

    Perhaps the tag added was wrong? You can add in the tag’s slug to be sure.

    Please refer to this documentation on how to use this particular function to get a better idea on what to put in it:
    https://developer.wordpress.org/reference/functions/has_tag/

    Note: The particular snippet only works for tags, if you want it applied for categories as well, you’ll have to add in_category() condition.

    A wise man once said:
    "Have you cleared your cache?"

    #1607678
    Matej

    Has_tag works.

    Thank you very much!

    #1607695
    Elvin
    Staff
    Customer Support

    Nice one. No problem. Glad it works for you. 🙂

    A wise man once said:
    "Have you cleared your cache?"

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.