Tag Info

Hot answers tagged

2

Whenever you add a new item to WordPress Menu ( Appearance -> Menu ) it creates a new Post of Post Type nav_menu_item and gets assigned a post meta called _menu_item_object_id with the main Post ID. For example, if I create a page called "Home" it gets assigned a Post ID of 2. Now, when I go to Menus and add the page to a menu, WordPress creates a new ...


2

This is relatively easily done using the walker_nav_menu_start_el filter (without all that PHP tag spam): function nav_replace_wpse_189788($item_output, $item) { // var_dump($item_output, $item); if ('Profile' == $item->title) { global $my_profile; // no idea what this does? if (is_user_logged_in()) { return '<div class="img" ...


1

I think this is a bad case of taxonomy split introduced in WP 4.2 ref. https://make.wordpress.org/core/2015/02/16/taxonomy-term-splitting-in-4-2-a-developer-guide/ Solution for this would be to use this plugin to detect and fix the splitting before Updating menus which is a bit buggy in my opinion. Update nav menus will trigger ...


1

For outputting only li's add this to wp_nav_menu array: 'container' => '', 'items_wrap' => '%3$s',


1

I would avoid any core-related layout classes and just roll your own (you don't need bootstrap for this). In your PHP page handler, just kick out something like: <div class="wrap"> <div class="my-plugin-column"> How... </div> <div class="my-plugin-column"> you... </div> <div ...


1

There are several ways to answer that question, depending on what it is you are attempting to accomplish. To generalize, you need to create two queries: one to get all public posts and one to get all public taxonomies and terms. Getting both in one array is not practical as term objects and post objects have different formats - however you can construct your ...


1

It's a simple solution of Setting the menu position to Secondary navigation, AND Handheld Setting an empty menu for for position Primary navigation. In my screenshot I haven't removed the primary navigation though.


1

You can try this out : <?php global $my_profile; ?> <?php if (is_user_logged_in()){ $avatar = '<div class="img" data-key="profile">'.get_avatar( get_current_user_id(), 64 ).'</div>'; }else{ $avatar = ''; } ?> And your menu code should be like this $defaults = array( 'theme_location' => 'location of menu in ...


1

Add to your functions file and use wp_nav_menu_items add_filter('wp_nav_menu_items','wpsites_add_avatar_to_nav', 10, 2); function wpsites_add_avatar_to_nav( $items, $args ) { if( $args->theme_location == 'primary' ) return $items; $dude = get_avatar( get_current_user_id(), 48 ); if (is_user_logged_in()) : echo'<li ...


1

Found the answer. It might not be the best way to do it but it is working for now. I was looking on using a filter when the solution seems to be using a custom walker. class edited_menu_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", ...


1

I believe the filter you want is wp_get_nav_menus: function wp_get_nav_menus( $args = array() ) { $defaults = array( 'hide_empty' => false, 'orderby' => 'name' ); $args = wp_parse_args( $args, $defaults ); /** * Filter the navigation menu objects being returned. * * @since 3.0.0 * * @see get_terms() * * ...


1

Presonally, I would use some CSS workaround. In menu administration you can add CSS class to menu item (if the field is not displayed, you can find it in Screen Options), for example "profile-link". And than you can add something like this to your template HEAD section: <?php $avatar = get_avatar_url( get_current_user_id(), array('size' => 64) ); // ...



Only top voted, non community-wiki answers of a minimum length are eligible