Wordpress Nav Walker Anchor only in li - php

I have a custom wordpress theme and would like my menu to be a little different than Wordpress standards like this:
<div class="nav-bar">
<ul>
<li>
Home
Gallery
About Me
Contact Me
</li>
</ul>
</div>
I only manage to remove the <li> in my walker class but can't manage to move the links inside the 1 li tag.
Is there any way to achieve this?
Thank you in advance.
EDIT :
This was achieved now by using wp_get_nav_menu_items.

Related

PHP dynamic navigation submenu

I have created a dynamic nav menu for a website. The menu loads to each page from a separate file, therefore i am using php required on all pages. I am trying to highlight the menu item when visitor is on each page and i cannot use JS or jQuery. All should be done in PHP, CSS and HTML only.
So far, i have the following function in the navigation file:
<?php
function setActive($name){
global $pageName;
if ($pageName == $name){
echo "class='active' ";
}
}
?>
And example of a menu:
<ul>
<li ><a <?php setActive ('v')?> href="v.php">Home</a></li>
<li>
cd
<ul class="hidden">
<li>a</li>
<li>b</li>
</ul>
</li>
</ul>
The function works for main menu, but i cannot get it work for submenu pages. I want the item cd to highlight when visitor lands on page a.php or b.php.
Any ideas how to solve it?
Thanks

how to change the output of woocommerce shortcodes?

when I use woocommerce shortcodes it have a special layout of html as the output!
for example if i use the shortcode: <?php echo do_shortcode['[products]']?>
it will show the the products in a certain layout of html like this:
<div class="row">
<div class="product-grid">
<ul>
<li>
<li>
<li>
<li>
</ul>
</div>
</div>
and there is a certain layout of html inside the li.
now my question is how can i change the layout of html that the shortcode is generating?
1.GO TO functions.php of the corresponding plugin/theme root folder.
2.search this page by product-grid or any common class appeared in this layout.
3.You will find a function for this shortcode.

Wordpress Menu Selected State

I need help in changing the style of a li in selected state. I'm using a Custom wordpress template for my Pages. I dont wanna create several templates just to set the class of li on each pages to .selected.
anyway here is my code:
<nav class="topmenu">
<ul>
<?php wp_nav_menu( array( 'theme_location' => 'menu-2' ) ); ?>
</ul>
</nav>
I do have several pages and i added them in menu-2
You don't need to add .selected class to the menu. WordPress automatically adds following two classes to the current menu item. You can place the code of .selected class in these classes and it will work..
current-menu-item
current_page_item

Rearranging Drupal navigation menu

Good day.
I am trying to modify the navigation menu layout of a drupal theme. The problem is i'm not a coder, but can follow tutorials and understand bits and peaices.
What I have is a set of menus and sub menus. At the moment the sub menus expand below their parent menus. What I want is for the sub menus to expand but live below all the parent menus so it would look like the structure below.
How it currently looks
Navigation_Menu_One
Sub_Menu_One
Sub_Menu_Two
Sub_Menu_Three
Navigation_Menu_Two
Navigation_Menu_Three
What I want it to end up looking like:
Navigation_Menu_One
Navigation_Menu_Two
Navigation_Menu_Three
Sub_Menu_One
Sub_Menu_Two
Sub_Menu_Three
What I have figured out is that the menu system is built from the following class's
<ul class="menu">
<li class="first collapsed"></li>
<li class="first collapsed"></li>
<li class="collapsed"></li>
<li class="expanded active-trail"> (The expanded Menu)
<ul class="menu"></ul> (the sub menu I want to relocate)
</li>
<li class="collapsed"></li>
<li class="collapsed"></li>
<li class="collapsed"></li>
<li class="last collapsed"></li>
</ul>
So what I want to do is be able to add something to the page that would capture the
<ul class="menu"></ul>
that appears below the
<li class="expanded active-trail">
and relocate it to below the last class or another div.
I understand I will need to do this using PHP from one of the template files with in the theme. Would any one have any idea how I would go about doing this. The theme I am using is the Corolla theme if that helps at all, but I guess it would be the same for any theme.
Hi and welcome to StackOverflow.
It seems to me from your description that you should be able to achieve this without writing any code. Simply navigate to site building > menus > navigation and use the drag handles to move the sub menus so that they are underneath the desired menu item.

How to add a div class to Wordpress Auto Nav?

I have the following code to display all pages into a nav bar in Wordpress
<ul>
<?php wp_list_pages('title_li='); ?>
</ul>
Trying to figure out how to add a div class to each li?
You should be able to use link_before and link_after:
<ul>
<?php wp_list_pages('title_li=&link_before=<div class="myClass">&link_after=</div>'); ?>
</ul>
There's a section on styling the <li>s in the documentation.

Categories