Tag Info

New answers tagged

1

There's an easier way with no markup changes and minimal CSS. Live demo/fiddle here, code below: <ul> <li>1a</li><li>2a</li><li>3a</li><li>4a</li><li>5a</li><li>6a</li> </ul> ul { list-style: none; margin: 0; padding: 0; text-align: right; } li { ...


0

You need to wrap your two groups (left and right aligned items) in two containers. You than set float left, respectively right on those containers. <UL> <div class="pull-left"><li>1a</li><li>2a</li><li>3a</li></div> <div ...


0

You could use the function wp_get_nav_menu_items() instead of wp_query() to retrieve the menu items from a particular menu in the menu structure order. Once you've done that, you could loop through the menu items one by one to do with as you wish (including filtering them down further on type or other info). This is assuming all pages are in the menu (which ...


1

You may be able to use a WP_Query on nav_menu_item since it is its own post type. I've never done this but maybe it would work like you need it to, worth a shot. There are three other possibilities: Option 1 - Get Your Nav Menu Items There's a functions called wp_get_nav_menu_items() which will return you an array of your menu items that you can then loop ...


0

You might need to use 'add_theme_support' for 'nav-menus' as well. See line 2 below: if ( function_exists('wp_nav_menu') ) { add_theme_support( 'nav-menus' ); register_nav_menus( array( 'primary' => __( 'Main Menu, 'wsy' ), ), 'secondary' => __( 'Secondary Menu', 'wsy' ) ) ); } Then display your menu like so: $nav_menu = ...


1

Query parsing happens on every query run on a page, not just the main query. Your parse_tax_query is modifying the query for menu items in your menu. Check is_main_query() to make sure you only change the main query: function no_child_terms($query) { if( !is_admin() && $query->is_main_query() ){ ...


0

I am using this plugin: https://wordpress.org/plugins/font-awesome-4-menus/ which does exactly what you need. Go to your Screen Options panel (top right) and activate CSS Classes. Then add fa-home fa-fw to your CSS class field.


1

I had a very similar issue. I needed to target a specific wp_nav_menu() and replace the a links with a class. Here is my solution in reference to the OP: function theme_add_menuclass( $classes, $args ) { if ( $args->theme_location == 'your-menu-location' ) { return preg_replace( '/<li /i', '<li class="your-class"', $classes ); } ...


0

To show a page at the custom post type 'home' you need to create a regular page with that slug. You can then add the page to the menu. I think I saw this in a different answer somewhere, but can't find it right now.


2

What about setting a static page as a page for posts? Settings -> Reading -> Front Page displays One static page for front (for example Home) and another static page (Blog) for posts.


0

The following code get you default posts. (make changes accordigly but make sure post_type = 'post') <?php $args = array( 'posts_per_page' => 5, 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'post_date', 'order' => 'DESC', ...


0

I can suggest two step: Try to deactivate all plugins (howto: this and this); Check if the core of Wordpress hasn't broken. Compare sources in directories wp-admin & wp-includes (it's difficult, but I don't know easy way).


0

You have to install a mega-menu plugin see on codecanyon u can try it with css html php sample Mega Menu Jquery you can show post on screen in Screen option in menu


0

@raunak how about use jQuery jQuery(" ul li .menu-item").removeClass( "current" ); for adding to parent jQuery(".current-menu-parent").addClass( "current" );


1

When you create a menu, after adding your pages to it, and after saving once, you have to check the box at the bottom on the page to tell wordpress on which menu area of your theme you would like to add the menu. You can also assign menus in appearrance -> customize.


1

Here a very quick example. The idea is to add a new meta box in the menu configuration. add_meta_box is used in admin_head-nav-menus.php page: class Custom_Nav { function __construct() { add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); } public function add_nav_menu_meta_boxes() { add_meta_box( ...


0

<form method="post" action="options.php"> <?php if( $active_tab == 'tab_one' ) { settings_fields( 'setting-group-1' ); do_settings_sections( 'my-menu-slug-1' ); } elseif( $active_tab == 'tab_two' ) { settings_fields( 'setting-group-2' ); do_settings_sections( ...


1

Unfortunately is_category() not worked for me but if(in_category( 'articles' )) `in_category()` worked Codex reference for in_category().


0

Simpler is footer .menu-item { width:50%; float: left; }


0

Ended up hooking the nav_menu_css_class filter, and adding the appropriate class when needed. Like this: add_filter( 'nav_menu_css_class', 'add_parent_menu_class', 10, 2 ); function add_parent_menu_class( $classes, $item ) { $post = get_post(); if ( ! $post ) { return $classes; } if ( $item->url === get_bloginfo( 'url' ) . ...


0

I don't see the problem, aside from not enough information. You can just use an a-tag with a class, link it to whereever and then add a background-image via CSS. You can reuse the classes for identical images or use different classes for different images.


0

Will get_pages() work for you? http://codex.wordpress.org/Function_Reference/get_pages If I'm understanding your question correctly, you would want something like this: $children_of_page = get_pages(array( 'child_of' => $post->ID, 'parent' => $post->ID //defining both parent and child forces the list to only include direct children. ...


0

In order to make it work I had to regenerate the menu order. function custom_insert_service_menus($items, $menu, $args){ if($menu->slug != 'main-menu') return $items; // only run filter for main-menu $new_items = []; $menu_order = 1; foreach($items as $item){ $item->menu_order = $menu_order; $new_items[] = $item; $menu_order++; ...


2

As far as I've seen you're missing bootstrap CSS grid markup inside your page div, so to start add container class to page div and below that a .row element, for more inforamation on how the Bootstrap grid works check documantation and remember that all Js and styles are based on the correct markup selectors_


0

Your html structure should look like <ul class="parent-class"> <li>Page 1</li> <li> <ul class="child-class"> <li> Sub menu item 1</li> <li> Sub menu item 2</li> </ul> </li> </ul> Wordpress should automatically add an "active" class to the active page then ...


0

You are correct that this is definitely a CSS issue. To get the 3rd level menu to show up fully, you'll want to target it and move it X number of pixels from the left until it lines up correctly. If your sub-menu's have a set width, then use that set width to move the 3rd level into the correct position. For example if my sub-menu's had a fixed width of ...


6

Using a custom Walker, the start_el() method has access to $depth param: when it is 0 the elemnt is a top one, and we can use this info to maintain an internal counter. When the counter reach a limit, we can use DOMDocument to get from full HTML output just the last element added, wrap it in a submenu and add it again to HTML. Edit When the number of ...


4

Got a working function, but not sure if it is the best solution. I used a custom walker: class Custom_Walker_Nav_Menu extends Walker_Nav_Menu { function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $classes = empty( $item->classes ) ? ...


7

There even is a way to make this possible with CSS alone. This has some limitations, but I still thought it might be an interesting approach: Limitations You need to hardcode the width of the dropdown Browser-Support. You basically need CSS3 selectors. But everything from IE8 up should work, although I haven't tested this. This is more of a ...


6

You can use wp_nav_menu_items filter. It accepts menu output and arguments which hold menu attributes, like menu slug, container, etc. add_filter('wp_nav_menu_items', 'wpse_180221_nav_menu_items', 20, 2); function wpse_180221_nav_menu_items($items, $args) { if ($args->menu != 'my-menu-slug') { return $items; } // extract all ...


0

Found the problem: on a mamp environment with ssl activated, on installation wordpress setted the database url options with https in front. Just changed theme to http on the remote server. On the local mamp enviroment I had also to restart the server without ssl.


0

Without knowing the specifics of your theme I can't say if a plugin exists that does this. That said, if you are comfortable with PHP something like this would do the trick: My Profile<?php if($user->hasMessages()):><img src="/path/to/icon"><?php endif;?> Do you have a code sample to look at, I could be much more specific if you did.


0

From first view this seems to be tough job, but actually even I having small skills of php could solve this problem just adding following code to my custom walker class: if ( $depth == 1 ) { // remove this statement if depth check is not required if (wp_get_nav_menu_object($item->title)) {// checking if item name matches to menu name $item_output ...


1

I believe that this plugin will do what you want. Jamocreations Auto Submenu https://wordpress.org/plugins/auto-submenu/ Here is also a link to the author's site, http://jamocreations.com/en/artikelen/auto-submenu , where he discusses why he built the plugin and also two other plugins that also work similarly. The advantage of the Jamocreations Auto ...


1

My solution to this problem when extending the Walker_Nav_Menu was to skip check if current_page_parent when C.P.T. I identified C.P.Ts following this stackexchange post. This does not entirely solve the problem as I am using current_page_item for C.P.T parent menu items, but it does achieve the desired outcome. Here is my class. class My_Menu extends ...


0

Given the amount of customization you're looking to make, your best bet may be to integrate a custom Walker function. From the Codex: For deeper conditional classes, you'll need to use a custom walker function (created in the 'walker' => new Your_Walker_Function argument). The easiest way to build a new walker function is to copy the default ...


2

I've asked this question a bit to early, but to help others in the feature here's the solution. For the menu editor to appear, you need to register a menu first: add_action( 'init', 'register_header_menu' ); function register_header_menu() { register_nav_menu('header-menu',__( 'Header Menu' )); } Or as pointed out by Howdy_McGee: add_theme_support( ...


0

Menus are included in native WordPress export. It's not too convenient that natively you can't only export menus though. From quick look up there is WordPress Menu Exporter plugin available in official repository for that. Export/import aside there are more options to automate it, such as set up scripts with WP CLI or simply using PHP code to detect empty ...



Top 50 recent answers are included