[Support request] Header Menu: Current Page

Home Forums Support [Support request] Header Menu: Current Page

Home Forums Support Header Menu: Current Page

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #508475
    Andrey

    Hi.
    Is it possible to remove a hyperlink from current page menu button? It is linking to itself now.

    #508571
    Tom
    Lead Developer
    Lead Developer

    You 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;
    }
    #508645
    Andrey

    Thank you, Tom!
    Another question: is there any simple way to add custom icon to widget title?

    #508805
    Leo
    Staff
    Customer Support

    The widget title field should accepts HTML. Is it not?

    #509119
    Andrey

    It’s not. Or I don’t know how to add it..

    #509261
    Leo
    Staff
    Customer Support
    #514411
    Vl

    Hi 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!

    #514428
    Vl

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

    #514828
    Leo
    Staff
    Customer Support

    Hi there,

    Do you mind opening a new topic as yours isn’t related to the original topic.

    Thanks!

    #514957
    Vl

    OK, no problem.

    #515000
    Leo
    Staff
    Customer Support

    Thanks 🙂

    #1911921
    Mihail

    You 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?

    #1911956
    Leo
    Staff
    Customer Support

    If your works for you then it’s probably better than Tom’s CSS.

    There isn’t a recommendation for this.

    #1912092
    Mihail

    What about the SEO? How do both codes affect SEO?
    I know that self-links (links to the current page) are bad for promotion.

    #1912113
    Leo
    Staff
    Customer Support

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

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.