How to show only one category in breadcrumb navigation

get_the_category() function used to retrieve categories array of a post, and array_shift() function used to get the first item of an array. You possibly need this – function ux_breadcrumbs() { if (!is_home()) { echo ‘<a href=”‘; echo get_option(‘home’); echo ‘”>’; bloginfo(‘name’); echo “</a> » “; if (is_category() || is_single() ) { if( is_category() ) { … Read more

Customize the Dashboard Menu Editor

I found the answer after I typed out the question so I’ll post it at the same time. The solution is to set the show_in_nav_menus option to false when registering the Custom Post Type. http://codex.wordpress.org/Function_Reference/register_post_type show_in_nav_menus (boolean) (optional) Whether post_type is available for selection in navigation menus. Default: value of public argument

Get category ID from nav menu

This is quite complex (both the question and the way to achieve what was asked for). You would have to set up a new Walker. In fact, you only need a custom start_el function, in which you check if you need/want to build a pull down area or not. You (could) do this with respect … Read more

Add class active to static menu

What you’ll need to do is use get_ancestors(). Pass get_ancestors() your current page ID, and then search the resulting array for the menu item ID. If the menu item ID is in the array, set the class to active.

Debugging – trying to add search box to menus

wp_nav_menu_items aren’t mentioned in the codex, so there are no concrete description on how to use it. wp_nav_menu_items can be found on line 347 in wp-includes/nav-menu-template.php $items = apply_filters( ‘wp_nav_menu_items’, $items, $args ); within wp_nav_menu. In the codex, it states the following Displays a navigation menu created in the Appearance → Menus panel. So this … Read more

getting parent page id when using custom menu.

Not sure if this is robust enough, but it shows basic traversal through menu to look for current post first then for its menu parent: /** * @param mixed $menu * @param int $post_id * * @return WP_Post|bool */ function get_menu_parent( $menu, $post_id = null ) { $post_id = $post_id ? : get_the_ID(); $menu_items = … Read more

How to make theme elements customizable in wordpress?

As per comments: this is what the Customizer API is for. In the case of the header there are a dozen parameters to tweak the behaviour with. Like this: $defaults = array( ‘default-image’ => ”, ‘width’ => 0, ‘height’ => 0, ‘flex-height’ => false, ‘flex-width’ => false, ‘uploads’ => true, ‘random-default’ => false, ‘header-text’ => … Read more

Make parent page only link to first subpage

class Themeslug_Page_Navigation_Walker extends Walker_Nav_Menu { function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { $id_field = $this->db_fields[‘id’]; if ( !empty( $children_elements[ $element->$id_field ] ) ) { $element->url = $children_elements[$element->$id_field][0]->url; } Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } } This did the trick.