For inject <span>
into menu, you do it using below code:
//Setup this code into your current function.php file
add_filter('wp_nav_menu_items','add_span_in_menu', 10, 2);
function add_span_in_menu( $items, $args ) {
if( $args->theme_location == 'primary') {
$myContent="YOURCONTENT"
$items .= '<li><span class="number">' . $myContent . '</span></li>';
}
return $items;
}
Above snippet will add <span>
with content to your WordPress menu. Hope this help you well!
Related Posts:
- Making update notification functionality for my themes
- Should `get_template_directory_uri()` be escaped?
- Best practice for including plugins as part of a theme?
- Modular theme settings
- How to disable 3.1 “Admin Bar” via script for the admin user?
- Where do I find the functions triggered within a hook?
- How to determine the current widget’s parent container (sidebar widget id)
- Is it possible to display the admin bar while in the Theme Customizer?
- two tinyMCE editors in the same page
- How to Change CSS Variable value in Theme Customizer Live Preview
- Pagination & get_pages?
- Custom nav menu is created with default pages, but not hooked to theme’s custom menu location
- index.php is not loaded for single posts
- Easy WordPress theme creation tutorial? [closed]
- How do I add a post to a menu
- Demo Import changes terms ids
- how to change WordPress menu markup/classes
- Best practices: Custom theme sidebar menu – hardcode or widget?
- Is it a good idea to make whole theme widgetized?
- how to implement wp_is_mobile on themes?
- Where is definied the theme location for the main menu in a WordPress template?
- How to get the URI to a theme without the domain. Example: /wp-content/themes/my-theme
- How to disable automatic colors in the Twenty Twenty theme?
- Check if user has enrolled in Sensei LMS Course on Lesson Page
- How to handle custom form submission?
- menu behavior is not as expected
- My custom theme does not load the translations
- Part of Menu Item Hidden on Header Menu
- Child theme style.css versioning
- Disable front-page.php template
- Gutenberg – editor-font-sizes in functions not working
- Same ACF on two different pages
- A mystery 300px image size
- How to use get_template_part instead of include_once?
- How to remove comment link title attribute?
- Custom Field returning Numerical Value for Image rather than URL
- which is the best way to customize nav-menu-template.php?
- Should we use ob_start() in WordPress short code
- wp-cli: For development, how can I activate a theme that is on the local disk but not zipped?
- Default string not appearing want to translate
- How to make a local cache of mshots images
- Why is the Page Template dropdown menu using the wrong file name?
- Using a page as home, how do I prevent nav from setting both home and page links active?
- 2 localizations inside a WordPress theme
- How can I ping update-core.php with a script?
- Custom theme updater – random string in new theme name
- Show woocommerce categories on my theme menu styling
- Child Theme’s style.css not loading in mobile browser
- How to Find the Page the Front Page is Using?
- My jQuery is enqueued properly. So why isn’t it working?
- Database Tables in WordPress Theme
- 3 Level Deep Navigation Menu Not Showing All Levels
- Broken theme, template is missing
- WordPress page/blog incorporated into static website
- wp_enqueue_script not working?
- Random white space before doctype
- Theme Development -> Specific Homepage
- Premium theme licensing of php called through AJAX
- is_single() works in plugin, not in theme?
- Do I need to create a child theme for JointsWP
- why mytheme/single-product.php works but not mytheme/woocommerce/single-product.php
- Issue on Accessing To Ajax Enqeued File to Pass to URL for Ajax Call
- pass wordpress template directory into ajax url call
- theme-independent CSS/JS files
- What is the need for the static front page [closed]
- Javascript development in Custom Themes
- Custom jquery not code not working in wordpress
- License of the used Bootstrap Theme is not GPL compatible
- Customize Option Framework
- How to include posts with a theme
- Under theme folder, what’s sequence of action for index.php, page.php, single.php?
- Register a custom post type as public = false, but have content appear in search engines?
- Theme author.php transfer
- restrain filter on get_the_excerpt to queried item in stead of current post
- Array for WordPress Avatar Size and Class
- How to display only author’s name for the current post?
- How can I include custom Gutenberg Blocks in a theme?
- WordPress displaying two different headers, one at top and one below footer
- How to show metabox on page if it is using a template
- Mix it up & WordPress
- two col layout bootstrap 4 with one fixed col and fade in effect on image
- Styling the website via the customizer – do the changes stay after theme update?
- annoying “Confirm Form Resubmission” message
- image sizes – finding and removing
- Changes to template not showing up unless ?reset=1 added to URL
- How do I keep images in posts below a certain size without editing the post?
- Theme options not displaying correctly after theme update
- Multiple Content Shortcodes
- Is it possible to customize the layout of Gallery Shortcode?
- How can i use archive.php for indexing wordpress default posts?
- Add the ability of changing background color of a theme [closed]
- How to use esc_attr__() function properly to translate a variable that contains string?
- What to do when child theme is out of date with parent theme
- How to make website with many template that active [closed]
- Query for tag given slug
- Image Size wrong during upload
- How can I add a single image from a gallery into the page header?
- ways to create customized theme (hard coded – no pagebuilder)
- Can’t select my block by clicking on it on apiVersion – but using blockProps
- Webpack does not create or update index.asset.php file in build folder