<a>
tags without <ul>
or <li>
.You're trying to convert a Webflow <a>
-based navbar to a WordPress-compatible ul > li > a
structure without changing your existing CSS. This is challenging because WordPress menus output an unordered list format by default, while Webflow uses standalone <a>
tags. Here’s how to bridge that gap without altering your stylesheet.
<a>
) tags, similar to Webflow.ul
and li
wrappers in the HTML output.In your WordPress theme's functions.php
, add a custom walker that strips the ul
and li
tags.
Use a stripped-down walker like this:
```php
class Webflow_Nav_Walker extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = null ) {
// No
function end\_lvl( &$output, $depth = 0, $args = null ) { // No </ul> output}function start\_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { $output .= '<a href="' . esc\_attr($item->url) . '" class="nav-link">' . $item->title . '</a>';}function end\_el( &$output, $item, $depth = 0, $args = null ) { // No </li> or similar output}
}
```
Note: Adjust class="nav-link"
to match your Webflow class names.
In your theme’s header.php
or wherever the menu appears, replace your current wp_nav_menu()
call with:
```php
wp_nav_menu(array(
'theme_location' => 'primary',
'container' => false,
'walker' => new Webflow_Nav_Walker()
));
```
This outputs only the <a>
tags per menu item, matching Webflow’s structure.
Add this filter to prevent unwanted class/id output:
```php
add_filter('nav_menu_item_id', '__return_null');
add_filter('nav_menu_css_class', '__return_empty_array');
```
To make a WordPress menu match Webflow’s <a>
-only navbar structure without changing your CSS, use a custom walker class that suppresses <ul>
and <li>
output and renders only <a>
tags. This routes WordPress menus through a structure compatible with your Webflow design.