• chordzillastatistics

    (@chordzillastatistics)


    Hey everyone,

    Can someone help me identify which files are responsible for displaying links in the theme’s menu? I am using a standard two-level menu. I need to find the theme files that output the menu so I can add microdata. I found the file nav.php, which has the line 'link_before' => '<span class="text-wrap">' that outputs the menu item titles. But I couldn’t find where the actual URLs are outputted. Can anyone help me with this?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @chordzillastatistics,

    Thank you for reaching out,

    As you’ve found, nav.php file is crucial for rendering the navigation. It handles the structure of the menu, including the link_before and link_after parameters.

    All menu items are in header.php
    Also, to make changes in the menu, you must modify the walker; you can find it in the following directory: theme root / inc / walker / menu-walker.php

    Please note that, if you’re modifying walker.php, consider creating a child theme to preserve your changes during theme updates.

    I hope it helps.
    Best Regards

    Thread Starter chordzillastatistics

    (@chordzillastatistics)

    Do I need to make changes in these lines of menu-walker.php?

    // Output
    $item_output = $args->before;
    $item_output .= '<a' . $attributes . ' class="menu-link">';
    $item_output .= $args->link_before . $title . $args->link_after;

    // Description
    if ( $item->description && 0 != $depth ) {
    $item_output .= '<span class="nav-content">' . $item->description . '</span>';
    }

    $item_output .= '</a>';

    It seems that when I make changes here, nothing happens.

    I added this file to the child theme. Could it be that it’s not being included? Do I need to connect it to the child theme somehow, or is it enough to recreate the same folder structure as in the main theme and just place the file there?

    Hello @chordzillastatistics,

    Thank you for reaching out,

    What exactly are you trying to do?
    Your question was: “I couldn’t find where the actual URLs are outputted.” Without knowing what you want to achieve, I can’t guide you effectively.

    In general, there’s no need to edit menu-walker.php directly, but you do need to understand this file to interpret the changes. As you mentioned, and as I pointed out above, you should edit the nav.php file.
    I also mentioned that you need to edit header.php. All header templates are located in the following path: Theme Root / partials / header This directory should be copied exactly into your child theme, and your changes should be made there.

    The location you need to edit is here: OceanWP Child Theme: nav.php (partials/header/nav.php) Line: 126

    Menu modifications require familiarity with PHP. If you don’t have sufficient experience with PHP, it’s better to consult an expert. Customizations of this type aren’t covered under support.

    Also, you should test your desired changes in an environment other than the production website.

    Additionally, without editing the code in the theme, you can create the desired HTML for the header and place it in the custom header: https://docs.oceanwp.org/article/355-how-to-create-a-custom-header.

    I hope it helps.
    Best Regards

    Thread Starter chordzillastatistics

    (@chordzillastatistics)

    I need to include the file menu-walker.php in the child theme. The link output in the menu is defined on line 200 of this file, and I need to make some changes there. However, when I copy menu-walker.php to the child theme, the changes I make do not appear on the site. If I make changes in this file within the parent theme, everything works as expected. The file nav.php is already included in the child theme without any issues, but menu-walker.php is not being included.

    Hello @chordzillastatistics,

    Thank you for reaching out,

    In the theme, only templates like the header, single blog post, or single product templates can be overwritten. The main functionalities or included libraries in the theme cannot be overwritten by creating a new file.

    To edit menu-walker.php, you would need to call this file again in the child theme. This requires significant customization. Additionally, it is not recommended to do this, and I must say that this falls outside the scope of support, so we cannot assist with this matter.

    Thank you for understanding,
    Best Regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.