Follow us on Youtube.  | Follow Website !

Search Suggest


How to insert custom items into the WordPress menu


How to insert custom items into the WordPress menuAre you looking for ways to insert custom items into the WordPress menu? Navigation menu helps your visitors navigate your website to find what they're looking for. Sometimes to help visitors with you more or to make your side menu more interesting, you need to add some custom items to it.

Unfortunately, WordPress does not make this easy for newbies. You will need to add the custom section you want by using the code at file.php. It's not too hard to do, but if you want to get creative with your own menu, you'll need some coding knowledge. Today, I will show you how to insert a custom item into your WordPress menu with a few codes.

Why add custom items to the menu your?


Let's face it, the biggest obstacle facing a website is trying to stand out in a crowded environment. There is no sure method that is original, but adding features and custom items that match your website is the best approach to take. Only you know the experience you want your website to provide to your visitors.

Adding custom sections to your side menu helps you get there. The default menu items are perfect for what they do, but adding additional items to them like the search bar, login / logout links, and many other things really make a difference. The only limiting factor to adding custom sections is your coding experience.

Remember that you find a lot of different party items that you added. You can use this template to create your own custom code.

How to insert custom items into the WordPress menu

Today, I will show you how to insert a custom item into your WordPress menu with a few codes. I will show you how to locate your.php file and some samples of what is added. Any experience with PHP / HTML / CSS coding will certainly help you create exactly what you want.

Remember before you begin, you need to enable custom menus. If you don't, nothing will happen.

Find the Ham.php file

Start by logging into cPanel and then clicking on the File Manager option. File Manager will let you access all files related to your website.


You need to locate the file.php inside the topic. Click the public_html directory, then click the wp-content directory. In this directory, you will find all content related to your website. Click the topic folder and enter the folder next to the topic you are currently using. Finally, right click on the file.php. then select the Edit option.


A popup window will appear. This box will alert you to create a backup copy of your file before editing anything. This will ensure you revert your website back when it works if something goes wrong. Click the “Edit” button. A new tab will open containing all the code from the file.


See more: Instructions on how to install WordPress when using cPanel

Add custom sections to the WordPress menu

You are now in the file.php. All that's left to do is add the code. The code you add completely depends on what you want to do. The first thing you will need is a basic code-side structure, like this:

add_filter ('wp_nav_menu_items', 'custom_item', 10, 2);

function custom_item ($ items, $ args) {

if (is_single () && $ args-> theme_location == 'primary') {

$ items. = '

  • Show whatever
  • ';


    return $ items;


    Here is a sample of the basic code structure you'll use. You will need to change “custom_item” to the actual item. There is an If statement inside the function, but if you don't want to use it, just delete it and replace it with what you need.

    So, for example, a good item to add is the search bar into your WordPress menu. The code with this looks like this:

    add_filter ('wp_nav_menu_items', 'search_box', 10, 2);

    function search_box ($ items, $ args) {

    if ($ args-> theme_location == 'primary')

    return $ items. "


    return $ items;


    As you can see, “custom_item”, which has been replaced by “search_box”, needs code to create and then adds the search bar included in the If statement.

    Once you have inserted the code into the file.php, click the “Save Changes” button to finish.


    Congratulations, you've successfully added your custom section to your WordPress menu. Following the same technique, you can add any kind of custom item to your side menu. The only limiting factor is your coding experience.

    Work for menu by your side exciting

    The menu is the first thing new visitors will search for. They need to find what your website offers and the menu that will lead them there. Making them most visually appealing when it comes to including the features they need is essential, but not easy. Make sure your side menu is working correctly. Add custom sections to your side menu to help them achieve what they designed.

    Post a Comment