[Resolved] generate_logo_href filter

Home Forums Support [Resolved] generate_logo_href filter

Home Forums Support generate_logo_href filter

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #579961
    Michael

    Hey GP’ers,

    I am using this filter and I’ve added it to the child theme’s functions.php. I wonder if it is possible to add something to it, so it will ONLY applly to the main blog (id_1) on multisite?

    Thanks in advance!
    Greetz,
    Michael

    #580164
    Leo
    Staff
    Customer Support
    #580701
    Michael

    Hi Leo,

    Thank you very much. I tried to add this code to the child’s theme:

    add_filter( ‘generate_logo_href’,’generate_custom_logo_href’ );
    function generate_custom_logo_href()
    {
    <?php if ( is_single( “POST ID NUMBER” ) ) : ?>
    <?php endif; ?>
    return ‘https://www.the-desired-domain.com&#8217;;
    }

    But the <?php if endif?> is not accepted in the child theme.

    I read about execute PHP must be enabled, I disabled that, I assume it only works in GP hooks?

    Have a nice day!

    Regards,
    Michael

    #580708
    Michael

    Addition to last sentence:

    Since I disabled execute PHP in GP Hooks I assume it only works in GP Hooks with the execute PHP enabled…

    😉
    Cheers!

    #580718
    Michael

    And not when added to the child theme…

    * not difficult at all to explain yourself when english is not your native language haha *

    #580867
    Leo
    Staff
    Customer Support

    Where did you add it in the child theme?

    It should be in function.php: https://docs.generatepress.com/article/adding-php/#use-a-child-theme
    so it definitely accepts php.

    Let me know 🙂

    #580896
    Michael

    Hi Leo,

    Thanks for your answer.

    add_filter( ‘generate_logo_href’,’generate_custom_logo_href’ );
    function generate_custom_logo_href()
    {
    // Enter the URL you want your logo to link to below
    return ‘https://www.the-desired-domain.com&#8217;;
    }

    is working fine in the functions.php, but if I add:

    add_filter( ‘generate_logo_href’,’generate_custom_logo_href’ );
    function generate_custom_logo_href()
    {
    <?php if ( is_single( “7” ) ) : ?>
    <?php endif; ?>
    return ‘https://www.the-desired-domain.com’;
    }

    It gives a red cross in front of the:

    <?php if ( is_single( “7” ) ) : ?>

    line, saying syntac error unexpected <. So i assumed that the conditional tag maybe only works when using GP hooks (not very logical but ok)
    As you say that is not the case, so now it seems that this code I try is wrong…or at least the syntax should be different. Can you maybe see the mistake in what or how I try to add this?

    Thanks a lot for your time and help!

    Kind regards!
    Michael

    #580904
    Leo
    Staff
    Customer Support

    Wrong quotation I think:
    <?php if ( is_single( '7' ) ) : ?>

    https://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page

    #580917
    Michael

    Thanks for that, those were wrong as well….But still same error:

    syntax error, unexpected ‘<‘

    in front of:

    <?php if ( is_single( ‘7’ ) ) : ?>

    Any other ideas?

    #580925
    Michael

    Hey Leo,

    Going through other posts on the forum I noticed that in other answers the first <?php is not there and it directly starts with the if….

    No error is returned when I add it that way, so probably that’s the issue!

    #580931
    Michael

    Nope haha that breaks the site, it returns an error at the end of the functions.php instead saying:

    syntax error, unexpected $EOF

    I make a mistake somewhere, obviously but for me unfortunately not obvious…

    #580983
    Michael

    YESSS!

    I got the following to work Leo:

    add_filter( ‘generate_logo_href’,’generate_custom_logo_href’ );
    function generate_custom_logo_href()
    {
    if ( is_single( ‘1’ || ( is_single( ‘2’)) ) ) {
    }
    return ‘https://www.desired-url.com&#8217;;
    }

    I needed it for 2 post’s to work so that’s why it changed a bit but man…I am happy!

    Many thanks for pointing me in the right directions!

    Have a nice day!

    #580984
    Leo
    Staff
    Customer Support

    I’m seeing some wrong quotation again.

    Try this:

    add_filter( 'generate_logo_href','generate_add_custom_logo_href' );
    function generate_add_custom_logo_href()
    {
        if ( is_single( '7' ) ) {
            return 'https://www.the-desired-domain.com';
        }
    
        return 'http://HomePageURL.com';
    }
    #580985
    Leo
    Staff
    Customer Support

    Glad you figured out 🙂

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