Issue after using php codes for adding navigation menus

Hi!

I used the teachings from this blog post https://premium.wpmudev.org/blog/add-menus-to-wordpress/?utm_expid=3606929-89.qobzZlXrS1uV61bna13Vlw.0&utm_referrer=https%3A%2F%2Fwww.google.ee%2F

to add more submenus. It resulted in the web page showing up fully blank ( consultius.ee).
The theme I am using is X-theme by themeco.

The parent theme functions php file looks like this:

<?php

// =============================================================================
// FUNCTIONS.PHP
// -----------------------------------------------------------------------------
// Theme functions for X.
// =============================================================================

// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
// 01. Set Paths
// 02. Require Files
// =============================================================================

// Set Paths
// =============================================================================

$func_path = 'framework/functions';
$glob_path = 'framework/functions/global';
$admn_path = 'framework/functions/global/admin';
$eque_path = 'framework/functions/global/enqueue';
$plgn_path = 'framework/functions/global/plugins';

// Require Files
// =============================================================================

//
// Debugging, conditionals, helpers, and stack data.
//

require_once( $glob_path . '/debug.php' );
require_once( $glob_path . '/conditionals.php' );
require_once( $glob_path . '/helper.php' );
require_once( $glob_path . '/stack-data.php' );
require_once( $glob_path . '/tco-setup.php' );

//
// Admin.
//

require_once( $admn_path . '/thumbnails/setup.php' );
require_once( $admn_path . '/setup.php' );
require_once( $admn_path . '/migration.php' );
require_once( $admn_path . '/meta/setup.php' );
require_once( $admn_path . '/sidebars.php' );
require_once( $admn_path . '/widgets.php' );
require_once( $admn_path . '/custom-post-types.php' );
require_once( $admn_path . '/customizer/setup.php' );
require_once( $admn_path . '/addons/setup.php' );

//
// Enqueue styles and scripts.
//

require_once( $eque_path . '/styles.php' );
require_once( $eque_path . '/scripts.php' );

//
// Global functions.
//

require_once( $glob_path . '/meta.php' );
require_once( $glob_path . '/featured.php' );
require_once( $glob_path . '/pagination.php' );
require_once( $glob_path . '/navbar.php' );
require_once( $glob_path . '/breadcrumbs.php' );
require_once( $glob_path . '/classes.php' );
require_once( $glob_path . '/portfolio.php' );
require_once( $glob_path . '/social.php' );
require_once( $glob_path . '/content.php' );
require_once( $glob_path . '/remove.php' );

//
// Stack specific functions.
//

require_once( $func_path . '/integrity.php' );
require_once( $func_path . '/renew.php' );
require_once( $func_path . '/icon.php' );
require_once( $func_path . '/ethos.php' );

//
// Integrated plugins.
//

require_once( $plgn_path . '/cornerstone.php' );

if ( X_BBPRESS_IS_ACTIVE ) {
require_once( $plgn_path . '/bbpress.php' );
}

if ( X_BUDDYPRESS_IS_ACTIVE ) {
require_once( $plgn_path . '/buddypress.php' );
}

if ( X_CONVERTPLUG_IS_ACTIVE ) {
require_once( $plgn_path . '/convertplug.php' );
}

if ( X_ENVIRA_GALLERY_IS_ACTIVE ) {
require_once( $plgn_path . '/envira-gallery.php' );
}

if ( X_ESSENTIAL_GRID_IS_ACTIVE ) {
require_once( $plgn_path . '/essential-grid.php' );
}

if ( X_LAYERSLIDER_IS_ACTIVE ) {
require_once( $plgn_path . '/layerslider.php' );
}

if ( X_REVOLUTION_SLIDER_IS_ACTIVE ) {
require_once( $plgn_path . '/revolution-slider.php' );
}

if ( X_SOLILOQUY_IS_ACTIVE ) {
require_once( $plgn_path . '/soliloquy.php' );
}

if ( X_VISUAL_COMOPSER_IS_ACTIVE ) {
require_once( $plgn_path . '/visual-composer.php' );
}

if ( X_WOOCOMMERCE_IS_ACTIVE ) {
require_once( $plgn_path . '/woocommerce.php' );
}

if ( X_WPML_IS_ACTIVE ) {
require_once( $plgn_path . '/wpml.php' );
}

if ( X_UBERMENU_IS_ACTIVE ) {
require_once( $plgn_path . '/ubermenu.php' );
}

if ( X_THE_GRID_IS_ACTIVE && x_is_validated() ) {
require_once( $plgn_path . '/the-grid.php' );
}

if ( X_EP_PAYMENT_FORM_IS_ACTIVE ) {
require_once $plgn_path . '/estimation-form.php';
}

function register_my_menus() {
register_nav_menus(
array(
'new-menu' => __( 'LisaMenüü1' ),
'another-menu' => __( 'LisaMenüü2' ),
'an-extra-menu' => __( 'LisaMenüü3' ),
'2-menu' => __( 'LisaMenüü4' ),
'3-menu' => __( 'LisaMenüü4' ),
'4-menu' => __( 'LisaMenüü5' ),
'5-menu' => __( 'LisaMenüü6' ),
'6-menu' => __( 'LisaMenüü7' ),
'7-menu' => __( 'LisaMenüü8' ),
'7-menu' => __( 'LisaMenüü9' ),
'8-menu' => __( 'LisaMenüü10' ),
)
);
}
add_action( 'init', 'register_my_menus' );

/*

header.php of the parent theme looks like this:

//<?php

// =============================================================================
// HEADER.PHP
// -----------------------------------------------------------------------------
// The site header. Variable output across different stacks.
//
// Content is output based on which Stack has been selected in the Customizer.
// To view and/or edit the markup of your Stack's index, first go to "views"
// inside the "framework" subdirectory. Once inside, find your Stack's folder
// and look for a file called "wp-header.php," where you'll be able to find the
// appropriate output.
// =============================================================================

//?>

<?php x_get_view( x_get_stack(), 'wp', 'header' ); ?>
<?wp_nav_menu( array( 'theme_location' => 'new-menu', 'container_class' => 'new_menu_class' ) ); ?>
<?wp_nav_menu( array( 'theme_location' => another-menu', 'container_class' => 'new_menu_class' ) ); ?>
<?wp_nav_menu( array( 'theme_location' => 'an-extra-menu', 'container_class' => 'new_menu_class' ) ); ?>
<?wp_nav_menu( array( 'theme_location' => '2-menu', 'container_class' => 'new_menu_class' ) ); ?>
<?wp_nav_menu( array( 'theme_location' => '3-menu', 'container_class' => 'new_menu_class' ) ); ?>
<?wp_nav_menu( array( 'theme_location' => '4-menu', 'container_class' => 'new_menu_class' ) ); ?>
<?wp_nav_menu( array( 'theme_location' => '5-menu', 'container_class' => 'new_menu_class' ) ); ?>
<?wp_nav_menu( array( 'theme_location' => '6-menu', 'container_class' => 'new_menu_class' ) ); ?>
<?wp_nav_menu( array( 'theme_location' => '7-menu', 'container_class' => 'new_menu_class' ) ); ?>
<?wp_nav_menu( array( 'theme_location' => '8-menu', 'container_class' => 'new_menu_class' ) ); ?>

How can I fix this besides deleting this code and child theme folder I created?

  • Adam Czajczyk

    Hello Endrik,

    I hope you're well today and thank you for your question!

    I checked the code and the issue is because of a small error in this part (that's from header.php file):

    <?php x_get_view( x_get_stack(), 'wp', 'header' ); ?>
    <?wp_nav_menu( array( 'theme_location' => 'new-menu', 'container_class' => 'new_menu_class' ) ); ?>
    <?wp_nav_menu( array( 'theme_location' => another-menu', 'container_class' => 'new_menu_class' ) ); ?>
    <?wp_nav_menu( array( 'theme_location' => 'an-extra-menu', 'container_class' => 'new_menu_class' ) ); ?>
    <?wp_nav_menu( array( 'theme_location' => '2-menu', 'container_class' => 'new_menu_class' ) ); ?>
    <?wp_nav_menu( array( 'theme_location' => '3-menu', 'container_class' => 'new_menu_class' ) ); ?>
    <?wp_nav_menu( array( 'theme_location' => '4-menu', 'container_class' => 'new_menu_class' ) ); ?>
    <?wp_nav_menu( array( 'theme_location' => '5-menu', 'container_class' => 'new_menu_class' ) ); ?>
    <?wp_nav_menu( array( 'theme_location' => '6-menu', 'container_class' => 'new_menu_class' ) ); ?>
    <?wp_nav_menu( array( 'theme_location' => '7-menu', 'container_class' => 'new_menu_class' ) ); ?>
    <?wp_nav_menu( array( 'theme_location' => '8-menu', 'container_class' => 'new_menu_class' ) ); ?>

    See the 3rd line above:

    <?wp_nav_menu( array( 'theme_location' => another-menu', 'container_class' => 'new_menu_class' ) ); ?>

    The "another-menu" slug should be enclosed fully within apostrophes (single quotation marks) but it's not. The line should be like this:

    <?wp_nav_menu( array( 'theme_location' => 'another-menu', 'container_class' => 'new_menu_class' ) ); ?>

    Adjust this and you should be good to go :slight_smile:

    Best regards,
    Adam

    PS. It would be really great if you could mark any code that you post here as a code using post editor "code" icon. Code posted "as is" sometimes may get corrupted and we then have no way of knowing if the result is because of how it was posted or if it's an "original error" that needs fixing. I believe that makes sense :slight_smile:

  • Adam Czajczyk

    Hello Endrik!

    The menus are visible because... they should be visible. The part of code in header.php file displays them. The way it's added now is just to display all these menus.

    This can of course be changed but I'd need to know where/how would you like to display your menus and also be able to check your site. If you need assistance with this, please

    - describe in details where/how these menus should show up
    - grant me a support access to your site so I could learn about how your theme is built; you can grant me an access by following this guide:

    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Best regards,
    Adam

  • Endrik

    Hi again Adam!

    According to my understanding the code should make the menus available in header. But they are NOT in header + the menus are made visible like 3x or 4x and the order is messed up + I added in total 10 places for menus, but there are more than 10 menus visible...

    Something is awfully wrong and I need it to be fixed asap...

    I have a trial account and I can't download the plugin u refered too. How can I give you access to the site?

  • Adam Czajczyk

    Hello Endrik!

    I understand your concerns but this is an issue that in order to be able to help you with I must see not only the code itself (the one that you are using) but also its implementation and the code/setup that "hosts" it.

    The plugin that is necessary to grant a support access is the "WPMU DEV Dashboard" and unlike other of our plugins it can be freely downloaded with Trial subscription. It's also installed just like any regular WP plugins. Please visit this page (make sure that you are logged in into your WPMU DEV account):

    https://premium.wpmudev.org/project/wpmu-dev-dashboard/

    There'll be a "Download" button so download the plugin, install it on your site and enable. It will then ask you to login to your account so use the same login and password that you are using to access this support forum.

    After that you'll be able to go to the "WPMU DEV -> Support" page in your site's dashboard and use "Grant Support Access" button. This will let me access and review your site securely.

    Let me know please when you are ready with this and I'll then access your site, check how these menus are displayed and how they are implemented and I'm sure will find the solution.

    Best regards,
    Adam

  • Dimitris

    Hey there Endrik,

    hope you're doing good and don't mind chiming in! :slight_smile:

    There's been an mis-conception here about navigations menus and menu items.
    A theme (and eventually a child theme) can provide multiple menu locations and each of them can have multiple menu items.
    As far as I understand (and please correct me if I'm wrong) you need multiple menu items instead of multiple navigation menus. I can see that you've created these extra navigations menus from your child theme but each of them contains a single menu item. What can be done here is:
    1. Delete all extra navigation menu created from your child theme. By doing so, deleting code from both functions.php and header.php files, you should remove the extra "Theme locations" options from the edit menu admin screen.
    2. Use the "Primary Menu" navigation menu already registered by X Theme and insert in there all of menu items. I already did so (created a "Primary Menu", added some elements and assigned it to "Primary Menu" location) in order to demonstrate to you the outcome.


    As you can see the "Primary Menu" navigation menu is inserting its content (menu items) on the very top bar besides the logo image.
    X Theme provides also a "Footer Menu" navigation menu which is being displayed on the very bottom of every page just above the "POWERED BY THE X THEME" text.

    For more detailed information on navigation menus I'd advise you to install our Integrated Video Tutorials plugin and search for a video labeled "NAVIGATION MENUS". :slight_smile:

    Feel free to post back here if more assistance is required on this!

    Warm regards,
    Dimitris

  • Endrik

    Hi again!

    Thanks for the help!

    I deleted the code from these function.php and header.php. Now my homepage is fully broken. Shwoing just white screen and some text. Damn... I did something wrong and I didnt make a back up, cooz I thought it was just a simple deleting of old implementations. I tried to resotre my earliest back up, but it didnt work out. Restore errors....

    I also have one more problem. I want to add unique background picture to the CONTENT area of each of my page. The pictures have beem uploaded to my wordpress. I didn't manage to get it to show these as a background for content, while I had the issue with the menus. Now I have 2 issues.

  • Predrag Dubajic

    Hi Endrik,

    Do you have any other modifications made to functions.php and header.php files?
    If not, you can just use the original files from the theme or completely remove those two files from your child theme, this should bring your site back.

    If you do have other changes you can check where the error is coming from by enabling WP debug in wp-config.php by replacing define('WP_DEBUG', false); with this code:

    // Enable WP_DEBUG mode
    define('WP_DEBUG', true);
    
    // Enable Debug logging to the /wp-content/debug.log file
    define('WP_DEBUG_LOG', true);
    
    // Disable display of errors and warnings
    define('WP_DEBUG_DISPLAY', false);
    @ini_set( 'display_errors', 0 );

    Refresh your site this should create debug.log file in your wp-content folder that could tell us what's causing the issue.

    I also had a look at your theme files and noticed that you have backslashes in header.php which might be causing this issue so try removing unnecessary slashes so your header.php looks like this:

    <?php
    
    // =============================================================================
    // HEADER.PHP
    // -----------------------------------------------------------------------------
    // The site header. Variable output across different stacks.
    //
    // Content is output based on which Stack has been selected in the Customizer.
    // To view and/or edit the markup of your Stack's index, first go to "views"
    // inside the "framework" subdirectory. Once inside, find your Stack's folder
    // and look for a file called "wp-header.php," where you'll be able to find the
    // appropriate output.
    // =============================================================================
    
    ?>
    
    <body <?php body_class(); ?>

    I also have one more problem. I want to add unique background picture to the CONTENT area of each of my page. The pictures have beem uploaded to my wordpress. I didn't manage to get it to show these as a background for content, while I had the issue with the menus. Now I have 2 issues.

    Could you start a new thread for this part and once we get your site back to normal we can check this out separately?

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.