1

I have a menu with 4 list items and i have 4 php files with different page structure. And when i try to navigate to to other page i'm getting that requested url was not found. I don't know what exactly i'm doing wrong or what i'm missing. All this i'm doing on local Xampp server. This what i made so far.

function.php

function main_menu() {
    add_theme_support('menus');
    register_nav_menus(array(
        'primary' => __('Primary Main Menu'),
    ));

Menu located in home page

<ul class="nav navbar-nav navbar-right">

        <?php 

            $args = array(
            'container' => false,
            'menu_id' => false,
            'items-wrap' => '',
                'theme_location' => 'primary'
            );

            //Remove class and id from li elements

            add_filter('nav_menu_item_id', 'clear_nav_menu_item_id', 10, 3);
            function clear_nav_menu_item_id($id, $item, $args) {
                return "";
            }

            add_filter('nav_menu_css_class', 'clear_nav_menu_item_class', 10, 3);
            function clear_nav_menu_item_class($classes, $item, $args) {
                return array();
            }

            wp_nav_menu($args);

        ?>
    </ul>

Also in admin panel i checked "Primary Main Menu" checkboxe.

5
  • Did you try to flush your Permalink first? The URL not found issue normally happens due to permalink issue. Go to Setting -> Permalink and just click save/update button. – Prabin Parajuli Jul 29 '17 at 17:22
  • i tried this already, didn't help – Andrew Jul 29 '17 at 17:24
  • 1
    are those 4 php files something like custom page templates, and attributed to 4 individual pages? are the menu links to those pages? what is the exact menu link that is not working? – Michael Jul 29 '17 at 19:06
  • yes they contains just other content, not working all of the menus except the main page. Basically the code that i posted its all what i've done, its my first wordpress project, maybe you can show an example how it must be attributed? – Andrew Jul 29 '17 at 19:27
  • What do your menu items link to exactly? You can't link directly to php files, that's not how WordPress works- you link to WordPress pages/posts/categories/etc., and you create templates for those pages according to the template hierarchy to customize the look. – Milo Jul 29 '17 at 19:47
0

Fixed issue by renaming each file for menu tempalte-{file-name}.php and adding at beggining of file

/*
    Template Name: Page name
*/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.