2011-11-10 37 views
7

Tôi muốn thêm một <span> trong menu wordpress chỉ sau <a> thẻ để nó sẽ giống nhưThêm khoảng trong menu wordpress

<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-4 current_page_item menu-item-13"> 
<a href="http://wordpress.org/"><span>Home</span></a> 
</li> 

giúp đỡ Bất kỳ này và đề nghị sẽ là đáng kể.

Trả lời

10

Hey nhờ cho r của bạn eply nhưng tôi đã nhận nó. Cần phải như thế này

<?php wp_nav_menu(array('theme_location' => 'primary', 'link_before' => '<span>','link_after'=>'</span>')); ?> 
-4

Nó trong file sau:

/wp-includes/nav-menu-template.php

sản lượng html bắt đầu trên đường dây 82

Hãy được tốt đẹp, đây là mã, thay thế từ dòng 82-109:

$output .= $indent . '<li' . $id . $value . $class_names .'>'; 

    $attributes = ! empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) .'"' : ''; 
    $attributes .= ! empty($item->target)  ? ' target="' . esc_attr($item->target ) .'"' : ''; 
    $attributes .= ! empty($item->xfn)  ? ' rel="' . esc_attr($item->xfn  ) .'"' : ''; 
    $attributes .= ! empty($item->url)  ? ' href="' . esc_attr($item->url  ) .'"' : ''; 

    $item_output = $args->before; 
    $item_output .= '<a'. $attributes .'><span>'; 
    $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after; 
    $item_output .= '</span></a>'; 
    $item_output .= $args->after; 

    $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); 
} 

/** 
* @see Walker::end_el() 
* @since 3.0.0 
* 
* @param string $output Passed by reference. Used to append additional content. 
* @param object $item Page data object. Not used. 
* @param int $depth Depth of page. Not Used. 
*/ 
function end_el(&$output, $item, $depth) { 
    $output .= "</li>\n"; 
} 

}

+0

Xin cảm ơn câu trả lời của bạn nhưng tôi đã hiểu. Nó phải như thế này 'primary', 'link_before' => '', 'link_after' => '')); ?> – NewUser

+0

Ngoài ra, bạn không bao giờ nên chỉnh sửa các tệp WordPress cốt lõi như thế. Nếu bạn thực hiện tự động, tất cả các thay đổi của bạn sẽ bị mất và có khả năng phá vỡ trang web. – navitronic

Các vấn đề liên quan