Connect with us

Wordpress Tips

[SOLVED] Remove Extra Class and ID from WordPress Menu

Nitesh Arya

Published

on

As you know WordPress comes with many defaults extra id and classes which make our website heavy which increases the loading time of our website, in order to optimize your WordPress you have removed these extra ids and classes.

Before optimize

<div class=”main-navigation“>
<ul id=”menu-primary” class=”menu”>
<li id=”menu-item-14″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-14″></li>
<li id=”menu-item-16″ class=”menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16″></li>
<li id=”menu-item-20″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-20″></li>
<li id=”menu-item-15″ class=”menu-item menu-item-type-taxonomy menu-item-object-category menu-item-15″></li>
<li id=”menu-item-17″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-17″></li>
</ul>
</div>

After optimize

<div class=”main-navigation“>
<ul id=”menu-primary” class=”menu”>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>

How to Remove Extra Classes and IDs from Wordpress Menu (wp_nav_menu)

In order to remove extra id and class, you have to just these PHP code inside your themes function.php file

add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);
add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1);
add_filter('page_css_class', 'my_css_attributes_filter', 100, 1);
function my_css_attributes_filter($var) {
  return is_array($var) ? array() : '';
}

then click on update file

Now delete cache file if you are using cache plugins then refresh page and then see source code of your website view-source:https://www.thenitesharya.com

See Screen Shorts As Demo

Remove Extra Class and ID from WordPress Menu

Continue Reading
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Wordpress Tips

Top 5 SEO Plugins for WordPress to Rank No 1 in Google Search

Nitesh Arya

Published

on

Top 5 SEO Plugins for WordPress to Rank No 1 in Google Search

If you want to make your wordpress base website to rank in google first page then these plugins can help you reach your goal easily.
Top 5 SEO Plugins for WordPress to Rank No 1 in Google Search

Top 5 SEO Plugins

  1. Yoast SEO
  2. Google XML Sitemaps
  3. All In One Schema Rich Snippets
  4. WP Super Cache or Wp Fastest Cache
  5. Autoptimize

1. Yoast SEO (Free Version)

yoast SEO is one of the most famous plugin for  making your website SEO friendly.

Thing It Do

It’s dealing with the writing your website title tag to make it SEO friendly so it can increase CTR rate and also search appearance
It’s Set canonical URLs to avoid duplicate content so don’t have to worry about Google penalties again.
Title and meta description templating for better branding and consistent snippets in the search results.
Content Keyword & SEO analysis: Invaluable tools to write SEO-friendly texts.
The snippet preview shows you how your post or page will look in the search results – even on mobile. DOWNLOAD LINK

 

2. Google XML Sitemaps

2nd and most used plugin in sitemap categories is Google XML sitemap, So what this plugin do? it generate xml sitemap for your website whenever you publish any content it generate XML sitemap and also send ping to google, bing ,Yahoo other types of search engine so your new page can easily be indexed by these search engine. DOWNLOAD LINK

 

 

 

 

3.  All In One Schema Rich Snippets

All In One Schema Rich Snippets this plugin is one of the widely used plugins for Schema.org reach meta tag. which make your website appear in Google search engine with rating star which increase your CTR Rate which result as High Ranking. DOWNLOAD LINK

4. WP Super Cache or Wp Fastest Cache

WP super cache or WP fastest cache with plugins are very very important for wordpress website. it’s make your website load really fast, what it does its generate copies of your website as a static page and serve people directly without involving in any kinds of PHP functions. It’s also Gzip your websites pages so user can get your website lighting speed fast.

DOWNLOAD LINKS DOWNLOAD LINKS

5. Autoptimize

Autoptimize optimizing your site. It can aggregate, minify and cache scripts and styles, injects CSS in the page head by default (but can also defer), moves and defers scripts to the footer and minifies HTML.
The “Extra” options allow you to optimize Google Fonts and images, async non-aggregated JavaScript, remove WordPress core emoji cruft and more. DOWNLOAD LINKS

Continue Reading

Trending

.