- This topic has 13 replies, 2 voices, and was last updated 5 years, 11 months ago by Leo.
-
AuthorPosts
-
May 20, 2018 at 5:18 am #579961Michael
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,
MichaelMay 20, 2018 at 9:27 am #580164LeoStaffCustomer SupportHi there,
I believe this is what you are looking for:
https://docs.generatepress.com/article/using-hooks-conditional-tags/#blog-posts-pageMore options here:
https://codex.wordpress.org/Conditional_Tags#A_PAGE_PageMay 21, 2018 at 6:02 am #580701MichaelHi 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,
MichaelMay 21, 2018 at 6:07 am #580708MichaelAddition 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!May 21, 2018 at 6:15 am #580718MichaelAnd not when added to the child theme…
* not difficult at all to explain yourself when english is not your native language haha *
May 21, 2018 at 8:33 am #580867LeoStaffCustomer SupportWhere 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 🙂
May 21, 2018 at 9:05 am #580896MichaelHi 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!
MichaelMay 21, 2018 at 9:16 am #580904LeoStaffCustomer SupportWrong quotation I think:
<?php if ( is_single( '7' ) ) : ?>
https://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page
May 21, 2018 at 9:40 am #580917MichaelThanks 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?
May 21, 2018 at 9:46 am #580925MichaelHey 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!
May 21, 2018 at 9:55 am #580931MichaelNope 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…
May 21, 2018 at 10:45 am #580983MichaelYESSS!
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!
May 21, 2018 at 10:45 am #580984LeoStaffCustomer SupportI’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'; }
May 21, 2018 at 10:46 am #580985LeoStaffCustomer SupportGlad you figured out 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.