Site logo

Archived topic

generate_logo_href filter

13 replies · Started by Michael on May 20, 2018

Viewing posts 1–14 of 14

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

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';
}

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

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!

And not when added to the child theme...

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

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';
}

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

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?

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!

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...

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';
}

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!

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';
}

Glad you figured out :)

This archived topic is closed to new replies.