Skip to content

Instantly share code, notes, and snippets.

@rhcarlosweb
Last active November 12, 2020 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhcarlosweb/5d2e50537fe0a6f698785f884867726d to your computer and use it in GitHub Desktop.
Save rhcarlosweb/5d2e50537fe0a6f698785f884867726d to your computer and use it in GitHub Desktop.
Walker Menu WordPress
<?php
/**
* Walker
*/
class WalkerHeader extends Walker_Nav_Menu {
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$object = $item->object;
$type = $item->type;
$title = $item->title;
$permalink = $item->url;
$taxonomy = $item->object;
$term_id = $item->object_id;
$colorlink = get_field( 'cat_color', $taxonomy . '_' . $term_id );
$output .= "<li class='" . implode( " ", $item->classes ) . "' data-color='" . $colorlink . "'>";
$output .= '<a href="' . $permalink . '" style="border-color: ' . $colorlink . ';" data-color="' . $colorlink . '">';
$output .= $title;
$output .= '</a>';
// $output .= print_r($item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment