How to add a div class to Wordpress Auto Nav? - php

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.

Related

Wordpress Nav Walker Anchor only in li

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.

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.

Magento Redirect URL?

Hellow friemds i develop a magento website and i created page and i want to linked that page into navigation menu bar
http://www.magentocommerce.com/knowledge-base/entry/adding-page-links-in-the-navigation-bar
Starting With Magento CE 1.7 there is an event that lets you add anything to the top menu.
The event is page_block_html_topmenu_gethtml_before. In the default theme, this is used to add categories in the menu. Check out the method Mage_Catalog_Model_Observer::addCatalogToTopmenuItems(). You can do the same.
If you are working on versions before 1.7 just edit the file app/design/frontend/{interface}/{theme}/template/catalog/navigation/top.phtml and add your link inside the ul element:
<ul id="nav">
<?php echo $_menu ?>
<li><?php echo $this->__('Text here')?></li>
</ul>
or like this
<ul id="nav">
<?php echo $_menu ?>
<li><?php echo $this->__('Text here')?></li>
</ul>
The approach for version 1.6 works in 1.7 also but it's not that clean.

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

Categories