2011-11-10 14 views
7

voglio aggiungere un <span> nel menù wordpress appena dopo <a> tag in modo che dovrebbe essere cosìAggiungere arco nel menu di 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> 

Qualsiasi aiuto e suggerimenti sarà apprezzabile.

risposta

10

Hey grazie per la r eply ma l'ho capito. Dovrebbe essere così

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

E nel seguente file:

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

uscita html inizia on line 82

Cerchiamo di essere bello, ecco il codice, sostituire da linea 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

Hey, grazie per la tua risposta, ma ho capito. Dovrebbe essere come questo 'primario', 'link_before' => '', 'link_after' => '')); ?> – NewUser

+0

Inoltre, non si dovrebbero mai modificare i file core di WordPress in questo modo. Se esegui un aggiornamento automatico, tutte le modifiche andranno perse e potenzialmente interromperanno il sito. – navitronic

Problemi correlati