Moin,
Im Moment arbeite ich mich ein wenig in Wordpress ein!
Zur Zeit beschäftige ich mich mit den Walker Nav Menü.
Mein Code bis jetzt schaut wie folgt aus
(Dieser funktioniert auch so wie er soll)
Code
class myHeader extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
//Add attributes to link element.
$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) . '"' : '';
$liAttributes = " class='";
$liAttributes .= ($item->current) ? "active" : "";
$liAttributes .= "'";
$liID = ($item->object_id) ? " id='menu-item-". $item->object_id . "'" : "";
$output .= "<li " . $liID . " ". $liAttributes . ">";
$output .= "<a" . $attributes . ">";
$output .= $args->link_before . apply_filters("the_title", $item->title, $item->ID) . $args->link_after;
$output .= "</a>";
}
function end_el(&$output, $item, $depth = 0, $args = array()) {
$output .= "</li>";
$output .= '';
}
}
Alles anzeigen
Allerdings möchte ich noch die Klasse Dropdown meinen Li-Element hinzufügen. Wie ermittel ich ob ein Eintrag weitere Einträge hat?
Grüße