- This topic has 8 replies, 3 voices, and was last updated 4 years, 6 months ago by
David.
-
AuthorPosts
-
November 11, 2021 at 11:11 am #2000662
Simon
Hi
I realise that the skip-link to #content effectively jumps over the category title on the archives, and jumps over the H1 title on posts with Hero images (using Dispatch).
To miss all the titles will be very confusing for someone relying on screen readers.
I know I can create an alternative div ID higher up by using a wonderful GP hook element, but can I also edit the skip link to go to it instead of #content ??
I’m sure someone must have asked this before, but I’ve searched and cannot find it.
Hope you can help. Thank you.
SimonNovember 11, 2021 at 3:46 pm #2000853David
StaffCustomer SupportHi there,
try this PHP Snippet to unhook the GP function and insert your own:
add_action('wp', function(){ remove_action( 'generate_before_header', 'generate_do_skip_to_content_link', 2 ); add_action( 'generate_before_header', 'custom_do_skip_to_content_link', 2 ); }); function custom_do_skip_to_content_link() { printf( '<a class="screen-reader-text skip-link" href="#your_section_id" title="%1$s">%2$s</a>', esc_attr__( 'Skip to content', 'generatepress' ), esc_html__( 'Skip to content', 'generatepress' ) ); }Just update the
#your_section_idfor your needsNovember 11, 2021 at 4:13 pm #2000866Simon
Wow. David thank you. I’ll try it and let you know.
November 12, 2021 at 5:47 am #2001325Simon
Thank you. It works.
I haven’t heard it on a screen-reader, but I can see the link is there:
<a class="screen-reader-text skip-link" href="#jump-nav" title="Skip to content">Skip to content</a>and lower down after the navigation I have the destination anchor which I created with a hook element after-navigation:
<div id="jump-nav"></div>It makes me think – on a mobile it is always tedious and confusing that links go to the standard page header rather than the content, yet on a larger screen it is right to do so because you can see both. Is there a simple way to make links eg to
/events/link instead to/events/#jump-navon mobile phones?November 12, 2021 at 7:07 am #2001394David
StaffCustomer Supporthmmm…. i am not even sure where to begin with ‘redirecting’ on mobile only. I think its going to require JS, maybe some bright spark on Stack Exchange has an answer…
December 7, 2021 at 10:05 am #2041508Rafał
Thank you, David! Again 🙂
I think it’s good for UX to enable smooth scrolling,
then link should have the corresponding classsmooth-scroll.<a class="screen-reader-text skip-link smooth-scroll" href="#your_section_id" title="%1$s">%2$s</a>December 8, 2021 at 3:34 am #2042183David
StaffCustomer SupportGlad you found it useful!
December 13, 2021 at 8:54 am #2047727Simon
Hi David – just to say I did find a solution to the question I posed above, about how to make a link eg to /events/ into a link instead to /events/#jump-nav on mobile phones. I used some code you offered elsewhere, but it was also one of those occasions when by clarifying the question you find the answer…
December 13, 2021 at 2:41 pm #2047977David
StaffCustomer SupportAwesome – so glad to hear that – and thanks for closing the loop with this topic.
-
AuthorPosts
- You must be logged in to reply to this topic.