- This topic has 20 replies, 3 voices, and was last updated 5 years, 9 months ago by Leo.
-
AuthorPosts
-
June 18, 2018 at 11:26 pm #603222Rachael
Hi, I am using different headers which each have a different site logo in them. I managed to set one of them to link back to the ‘homepage’ of that particular section (using the same header and logo). BUT, it changes it for all of the headers and logos. So, how can I set it for each different header?
I have this script in my hook wp_footer:
<script>
jQuery(document).ready(function($) {
var mobile, widthTimer;
mobile = jQuery( ‘.menu-toggle’ );function generateMoveNav() {
if ( mobile.is( ‘:visible’ ) ) {
jQuery(‘.main-navigation’).insertBefore(‘.site-logo’);
} else {
jQuery(‘.main-navigation’).insertAfter(‘.site-logo’);
}
}if ( mobile.is( ‘:visible’ ) ) {
generateMoveNav();
}jQuery(window).resize(function() {
clearTimeout(widthTimer);
widthTimer = setTimeout(generateMoveNav, 100);
});
});
</script>And this in functions:
add_filter( ‘generate_sections_sidebars’,’generate_enable_sections_sidebars’ );
function generate_enable_sections_sidebars()
{
return true;
}add_filter( ‘generate_logo_href’,’generate_add_custom_logo_href’ );
function generate_add_custom_logo_href()
{
if ( is_page( ‘erg-services’ ) ) {
return ‘http://test.ergapc.co.uk/erg-services/’;
}return ‘http://test.ergapc.co.uk/erg-services/’;
}It enables the logo to link back to that specific URL. But when I’m on a different page with a different header and logo, how can I also get it to link to a different URL for pages that use that header only? Basically, how can I duplicate that code but make it work for a specific header? Thanks.
June 19, 2018 at 8:41 am #603705LeoStaffCustomer SupportHi there,
No JS should be required
Looks like you are already using the correct filter:
https://docs.generatepress.com/article/generate_logo_href/But if you have both return to the same URL.
The URL inside the if statement should be the specific URL that you want that page to return to.
The URL at the end is for general return link.
Let me know if this helps.
June 20, 2018 at 1:31 am #604163RachaelIt is now:
add_filter( ‘generate_logo_href’,’generate_add_custom_logo_href’ );
function generate_add_custom_logo_href()
{
if ( is_page( ‘/erg-services/’ ) ) {
return ‘/erg-services/’;
}return ‘http://test.ergapc.co.uk/’;
}
But it does not work. Any suggestions please? Thanks.June 20, 2018 at 7:43 am #604385HeikoHello!
What about
if ( is_page( 'erg-services' ) ) {
instead ofif ( is_page( β/erg-services/β ) ) {
?Best regards,
HeikoJune 20, 2018 at 9:04 am #604509LeoStaffCustomer SupportYup the first notation is the correct one π
June 20, 2018 at 10:32 pm #604917RachaelThank you. But it now says “nonce_failure”. and does not work. I simply want each different logo in each corresponding header to be able to link to a different section using each corresponding header. Please can someone help with this?
June 20, 2018 at 10:42 pm #604918RachaelUpdate – it was caching. So it does work if I am on http://test.ergapc.co.uk/erg-services/ but if I click anywhere else within that section that is using that specific header, such as this page: http://test.ergapc.co.uk/erg-services/thermal/thermal-oxidisers/, it reverts to linking back to the main page which is http://test.ergapc.co.uk/. I need all of the pages that use a specific header to link to that ‘homepage’ of the section using that specific header.
Does this explain it better?
I have three different logos in three different headers. On the pages that use each of those different headers, I need the logo in each header to link to the ‘homepage’ for each section. So, when the user is on any of the pages within http://test.ergapc.co.uk/erg-services/ such as http://test.ergapc.co.uk/erg-services/thermal/thermal-oxidisers/ the logo in the header needs to link to http://test.ergapc.co.uk/erg-services/. If the user is on the maintenance page http://test.ergapc.co.uk/erg-maintenance/, I need the logo to link to http://test.ergapc.co.uk/erg-maintenance/ and if the user is on the main homepage of the entire site http://test.ergapc.co.uk then I need the logo to link to http://test.ergapc.co.uk (which it does do that now). The most important thing is for the logo in the /erg-services/ header to link to http://test.ergapc.co.uk/erg-services/ when in any of those pages using that header. Is there anyone who can help with this? Thanks.June 21, 2018 at 12:48 am #604962HeikoMaybe you should hire someone with coding skills. π Try this one:
add_filter( 'generate_logo_href','hm_generate_add_custom_logo_href' ); function hm_generate_add_custom_logo_href() { if ( is_page( 'erg-services' ) ) { return 'http://test.ergapc.co.uk/erg-services/'; } else if ( is_page( 'erg-maintenance' ) ) { return 'http://test.ergapc.co.uk/erg-maintenance/'; } else if ( is_page( '...' ) ) { return 'http://test.ergapc.co.uk/...'; } else return 'http://test.ergapc.co.uk/'; }
June 21, 2018 at 12:52 am #604963RachaelWell, I thought that was one of the reasons this support forum exists for Generate Press members. Thank you for that. I will try it out!
June 21, 2018 at 2:55 am #605025HeikoI thought that this would save you a lot of time. π
Indeed, the customer service here is extraordinary great, because they even answer questions which do not belong to GeneratePress itself and help wherever they can.
June 21, 2018 at 3:11 am #605030RachaelYes absolutely! It’s amazing support! What would help is if we could specify the logo URL link within each header in the Generate Press theme customization section.
The following is now working on every page apart from the main page http://test.ergapc.co.uk/ where it is linking to http://test.ergapc.co.uk/erg-services/ and should link to http://test.ergapc.co.uk/
add_filter( ‘generate_logo_href’,’generate_add_custom_logo_href’ );
function generate_add_custom_logo_href()
{
if ( is_page( ‘http://test.ergapc.co.uk’) ) {
return ‘http://test.ergapc.co.uk’;
}
else if ( is_page( ‘erg-maintenance’ ) ) {
return ‘http://test.ergapc.co.uk/erg-maintenance/’;
}else if ( is_page( ‘…’ ) ) {
return ‘http://test.ergapc.co.uk/erg-services/…’;
}
else return ‘http://test.ergapc.co.uk/erg-services/’;
}June 21, 2018 at 8:00 am #605322HeikoAnd why did you not use my code? With
else return βhttp://test.ergapc.co.uk/erg-services/β;
you specify the “rest” of your site which do not match the ones from your if-statements before. So this should be as in my code before. If you want to test your starpage, you can useis_home()
instead ofis_page()
. The exampleis_page('...')
was only a placeholder and should be changed or removed by you if you do not need another condition.June 21, 2018 at 9:06 am #605393RachaelI did try your code first and it didn’t work. None of the pages within /erg-services/ (which is the bulk of the site) linked to /erg-services/. They all linked back to http://test.ergapc.co.uk which isn’t right.
Now, everything is correct apart from when you are on http://test.ergapc.co.uk main page. That logo links to /erg-services/ and should either not link at all or simply link to http://test.ergapc.co.uk.
Sorry about the confusion. It’s nearly there. Thanks for your help.
June 21, 2018 at 9:13 am #605398LeoStaffCustomer SupportThe last line:
else return 'http://test.ergapc.co.uk/erg-services/';
should be
else return 'http://test.ergapc.co.uk';
June 21, 2018 at 9:28 am #605415RachaelThank you Leo but nope. That doesn’t work. It cause pages like this http://test.ergapc.co.uk/erg-services/water/odour-control/ to link back to http://test.ergapc.co.uk. All pages like that (that are under /erg-services/…) need the logo to link back to http://test.ergapc.co.uk/erg-services/
-
AuthorPosts
- You must be logged in to reply to this topic.