- This topic has 14 replies, 2 voices, and was last updated 2 years, 7 months ago by Leo.
-
AuthorPosts
-
February 28, 2018 at 6:59 pm #508475Andrey
Hi.
Is it possible to remove a hyperlink from current page menu button? It is linking to itself now.February 28, 2018 at 11:30 pm #508571TomLead DeveloperLead DeveloperYou can’t remove the link, but you can make it so it doesn’t do anything:
.main-navigation .main-nav ul li[class*="current-menu-"] > a { pointer-events: none; }
March 1, 2018 at 1:47 am #508645AndreyThank you, Tom!
Another question: is there any simple way to add custom icon to widget title?March 1, 2018 at 6:11 am #508805LeoStaffCustomer SupportThe widget title field should accepts HTML. Is it not?
March 1, 2018 at 11:54 am #509119AndreyIt’s not. Or I don’t know how to add it..
March 1, 2018 at 3:25 pm #509261LeoStaffCustomer SupportSomething like this might help then: https://generatepress.com/forums/topic/html-in-widget-title-no-longer-working/#post-445297
March 7, 2018 at 11:51 pm #514411VlHi Tom, Leo!
How to change the style of one menu item (font, background, size, margin-top, etc ..).
Does not work if I insert styles in this code:.main-navigation .main-nav ul li[class*=”current-menu-“] > a {
pointer-events: none;
}Thanks for your support!
March 8, 2018 at 12:34 am #514428VlAdditions to my previous message.
I need to change style of one menu item, so I inserted this code in the Menu Structure – Navigation Label:<span style = “background-image: url (/images/01.gif); background-repeat: no-repeat; background-position: left center; padding: 0px 0px 0px 30px; color: # FF0000; font-family: Impact; font-size: 24px; “> MAIN PAGE </ span>
How to create a class with these parameters to include this class in the Menu Structure – CSS Classes?
Thank you.
March 8, 2018 at 8:46 am #514828LeoStaffCustomer SupportHi there,
Do you mind opening a new topic as yours isn’t related to the original topic.
Thanks!
March 8, 2018 at 10:42 am #514957VlOK, no problem.
March 8, 2018 at 11:31 am #515000LeoStaffCustomer SupportThanks 🙂
August 29, 2021 at 9:52 am #1911921MihailYou can’t remove the link, but you can make it so it doesn’t do anything:
Tom, I found some code. As planned, he should remove the link on the current page.
The first option removes the link to the current page in all menus:
function wp_nav_menu_no_current_link( $atts, $item, $args, $depth ) { if ( $item->current ) $atts['href'] = ''; return $atts; } add_action( 'nav_menu_link_attributes', 'wp_nav_menu_no_current_link', 10, 4 );
The second option does the same for a specific menu:
function wp_nav_menu_no_current_link( $atts, $item, $args, $depth ) { if ( $args->theme_location == 'menu_name' ) { if ( $item->current ) $atts['href'] = ''; } return $atts; } add_action( 'nav_menu_link_attributes', 'wp_nav_menu_no_current_link', 10, 4 );
I have a question: is it possible to do this or is it still not recommended?
Or does your code and the codes I have given do the same thing?August 29, 2021 at 10:49 am #1911956LeoStaffCustomer SupportIf your works for you then it’s probably better than Tom’s CSS.
There isn’t a recommendation for this.
August 29, 2021 at 4:34 pm #1912092MihailWhat about the SEO? How do both codes affect SEO?
I know that self-links (links to the current page) are bad for promotion.August 29, 2021 at 5:47 pm #1912113LeoStaffCustomer SupportI don’t believe would have any effect on SEO but I’m not an SEO expert so might be best to check with someone like Yoast or Rankmath or even WordPress support team.
-
AuthorPosts
- You must be logged in to reply to this topic.