开发者

Changing the HTML code for the Dynamic Sidebar in Wordpress

I'm having a hard time trying to figure out the dynamic sidebar without hacking the php file. I'm rebuilding an old web site and I need to use custom HTML code instead of the generate code that's given in wp-includes/nav-menu-template.php.

In a nutshell, I need to go from:

<div>
  <ul>
    <li><a href="#">LINK NAME</a></li>
    <li><a href="#">LINK NAME</a></li>
    <li><a href="#">LINK NAME</a></li>
    <li><a href="#">LINK NAME</a></li>
  </ul>
</div>

To this code:

<div>
    <a href="#">LINK NAME</a>
    <a href="#">LINK NAME</a>
    <a href="#">LINK NAME</a>
    <a href="#">LINK NAME</a>
</d开发者_StackOverflow中文版iv>


For what you want you can create custom menu in admin as you did. Than in page where you want this paste this code:

<div>
<?php
  $items = wp_get_nav_menu_items("custommenu");
  foreach($items as $item): 
?>
  <a href="<?php echo $item->url; ?>"><?php echo $item->title; ?></a>
<?php endforeach; ?>
</div>

Replace custommenu with your menu name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜