Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #842381

    Hi all,

    I managed it to set different Logos on my Site with Advanced Custom Fields, this works perfectly. Now I also want set different Links on these Logos. I found the following code in a thread:

    add_filter('avf_logo_link','av_change_logo_link');
    function av_change_logo_link($link)
    {
        if(is_page(1)) { $link = "http://kriesi.at"; }
        if(is_page(2)) { $link = "http://kriesi.at/themes"; }
        return $link;
    }

    This is what I need, but I want to replace the “is_page” with the filename of an image. How do I have to change this code for this?

    Many thanks

    • This topic was modified 7 years, 4 months ago by owls_studio.
    #842479

    Hey owls_studio,

    I don’t think there is a code for that, you can refer to wordpress’ codex for the conditional tags you can use: https://codex.wordpress.org/Conditional_Tags

    Best regards,
    Nikko

    #842502

    Ok thanks. So another question: Is it possible to replace this code

    {
        if(is_page(1)) { $link = "http://kriesi.at"; }
        if(is_page(2)) { $link = "http://kriesi.at/themes"; }
        return $link;
    }

    with another PHP-Code?

    I want to add a filter like this

    add_filter('avf_logo_link','av_change_logo_link');
    function av_change_logo_link($link)

    with a PHP Snippet like

    <?php
    if (file_exists($filename)) {
        echo '<a href="$link_address">Link</a>';
    } elseif (file_exists($filename) {
        echo '<a href="$link_address">Link</a>';
    } 
    ?>
    #842519

    This is my Idea:

    add_filter('avf_logo_link','av_change_logo_link');
    function av_change_logo_link($link)
    {
        if(wp_attachment_is_image(your_image.jpg)) { $link = "your_link"; }
        if(wp_attachment_is_image(your_image.jpg)) { $link = "your_link"; }
    }

    but then allways the current Site appears as Homelink. I don’t see the problem here.

    • This reply was modified 7 years, 4 months ago by owls_studio.
    #842747

    Hi,

    I don’t think those codes will work, however since you mentioned you have managed to set different logos using ACF, I think you should be able to do the same the logo link using same method (with ACF) and tweaks in header.php

    Best regards,
    Nikko

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