WordPress Theme Support custom menus and modify the CSS style implementation method _delphi

Source: Internet
Author: User
In the production of WordPress theme When I encountered this problem, and encountered a CSS style error, in fact very simple, the operation is as follows:
Add in functions.php in the topic:
Register_nav_menus (' Menu ' => __ (' menu ', ') ');
Post the navigation code in the subject navigation bar: <?php wp_nav_menu (' Id=navbar ');?>
However, CSS style errors have occurred
The original output of this function is the following format:
Copy Code code as follows:

<div id= "MenuBar" >
<ul class= "Menus" >
<li class= "..." ><a href= "http://.../" >Home</a></li>
<li class= "..." ><a href= "http://.../" > menu item 1</a></li>
<li class= "..." ><a href= "http://.../" > menu item 2</a></li>
<li class= "..." ><a href= "http://.../" > menu item 3</a></li>
...
</ul>
</div>

It's OK, just filter it out:
Change the code to:
Copy Code code as follows:

<?php
Echo str_replace ("</ul></div>", "" ", Ereg_replace (" <div[^>]*><ul[^>]*> "," ", wp_nav_ Menu (Array (' theme_location ' => ' primary ', ' echo ' => false)));
?>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.