P
P
partizzend2016-04-03 10:12:30
User navigation
partizzend, 2016-04-03 10:12:30

How to duplicate menu item text in wordpress?

Hello, tell me how to duplicate the text of a menu item in a separate span in CMS WORDPRESS? Needed to create a hover effect.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Vorotnev, 2016-04-03
@partizzend

In the menu settings for this menu item, specify a custom CSS class, for example 'item-wrap', further in functions.php:

function pss_wrap_nav_item( $title, $item ) {

  if( in_array( 'item-wrap', $item->classes ) ) {
    $title = '<span class="item-wrap has-effect">' . $title . '</span>';
  }

  return $title;

}
add_filter( 'nav_menu_item_title', 'pss_wrap_nav_item', 10, 2 );

It is clear that the classes are out of your head, you can safely change them to your own. A class in the menu item settings is added to make it easier and easier to catch a specific menu item.

A
aarty20, 2016-04-05
@aarty20

you can simply copy or duplicate an element or any other data using js/jquery

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question