Tag Info

New answers tagged

1

There's a much simplier (and more secure way*) way than hiding the user interface (show_ui=false) and adding a custom metabox to only display terms. If you remove the capability of the user to manage terms, however, not only do you have a secure solution, but user interface takes care of itself. As part of the register_taxonomy() you can specify the ...


0

This code runs "wp_insert_term" only when needed (only when querying for all terms) for better performances register_taxonomy( 'categories', null, array( 'hierarchical' => true, 'labels' => array( 'name' => 'Categories' ), 'show_admin_column' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' ...


0

Yeah I found the answer an another website. Taxonomies have a restriction that they cannot have uppercase characters in their name they can only have lowercase and underscore characters. that`s the problem.


1

Ok, so the problem was that I was adding the variable outside the function. After some cleanup, code looks like this and it works! function roots_setup() { // Variables $header_type = get_field('header_type','options'); if (($header_type)=='brand-centered') { register_nav_menus(array( 'brand_centered_left' => __('Brand Centered Navigation (Left)', ...


1

Welcome to stackexchange. When asking a question please try to be as specific in your question as possible. Try describing what you want to know – also using screenshots or wireframes is ok – but please avoid forcing others to ckick on a link to understand your question. Questions like "How can I do this?" are usually not very likely to get a lot of ...


0

As I said, I've been missing a stupid detail in my CSS, there was a fixed height for all the li. Problem solved by removing it.


0

I can see a syntax error: replace 'theme-location' by 'theme_location'. Always think about underscores in Wordpress variables/functions names ;) wp_nav_menu() : https://codex.wordpress.org/Function_Reference/wp_nav_menu


0

Go to Dashboard > Appearance > Menus, then under your menu links you see Menu Settings. Check if position of each menu is checked as you want.


0

First, throw away your custom walker. Post URLs are called permalinks, and as with most things in WordPress, you can filter them! There is a filter called post_link that lets you modify the URL of the post before it's returned in get_permalink(). We can use this, along with the posts slug, and the home_url function to get something similar to this: ...


1

The best solution would be to allow a user to choose the nav menu location when adding/editing a page. Use a meta box with a dropdown (select) with all the available locations, and then save the selected location in a custom field: /** * Register the meta box. */ function wpse_183868_page_nav_menu_meta_box_register() { add_meta_box( ...


2

I guess you mean the wp_page_menu fallback, where you can use the filters wp_page_menu_args and wp_page_menu to modify it's output. Notice that this function is a wrapper for the wp_list_pages() function, that ships with the wp_list_pages_excludes and the wp_list_pages filters. That function is again wrapper for the walk_page_tree() function, that ...


1

to hide "HOME" label from wordpress navigation i use //change 105 with your home id #menu-item-105 span { display:none; } and for icon i use "Iconic Navigation" wordpress plugin


0

Use the WP database (via proper methods) to store a 'is this the first run' flag? Then just conditionally execute. check for flag in wp db if exist do nothing if not exist create me my menus dag nammit remember to set flag for next round so its only done once Something like that? If you need to regenerate then just flip the flag from within the code ...


0

I had the same problem. This is what I do: Change the YourMenuItem to your menu name item. /* Add a custom class to a specific menu item */ function my_class( $classes, $item ) { if ( $item->title == "YourMenuItem" ) { $classes[] = 'current-page'; } return $classes; } add_filter( 'nav_menu_css_class', 'my_class', 10, 2 );


0

Well, it is quite a hack I propose, but I would suggest the following: add_action( 'admin_head', 'chg_menu_on_special_pages_page' ); function chg_menu_on_special_pages_page(){ global $parent_file; $gallery_page_id = 2; if( $parent_file != 'edit.php?post_type=page' ) return; if( ! isset( $_GET['post'] ) || $_GET['post'] != ...


0

Perhaps you could define a function which just pulls in the post.php content and set it as your callback for add_menu_page(). But the slug parameter is not meant to accept variables. You will need to modify the $_REQUEST array to achieve that. Ex: add_menu_page( __( 'Gallery', '' ), __( 'Gallery', '' ), 'edit_posts', 'gallery-edit', 'gallery-edit-page', ...


0

Replace $page->post_title; with $item->title; to get the menu item's label


0

A little searching got me the nav_menu_link_attributes filter: function wpse183311_filter( $atts, $item, $args ) { $atts['itemtype'] = 'http://schema.org/SiteNavigationElement'; return $atts; } add_filter('nav_menu_link_attributes', 'wpse183311_filter', 3, 10); Add however many attributes you need to the $atts array as necessary


0

If you only seek to direct users instantly to the anchor point, you'd use mukto90's solution. However if you want the user to arrive at a page and then have it automatically scroll to the anchor point, you'll need to add SmoothScroll jQuery as well: $('a[href^="#"]').on('click', function(event) { var target = $(this.href); if( target.length ) { ...


0

Add this page link in navigation menu with #target_point, example http://example.com/contact#location_map Then add an anchor at somewhere of that page with name="location_map". Something like <a name="location_map"></a> Now when someone clicks on this menu, he'll be directed to this specific part of contact page.


0

Figured it out as I wrote out my question. Love when that happens. Here is the solution if someone needs this for the future. I simply just wrapped the desired output in a conditional to match the depth I needed. Viola> if ( 0 == $depth ) { $item_output .= "\n$indent<div class=\"dropdown\"><div class=\"container\"><div ...


0

Not answering the question but maybe answering the problem: If the arrows are used for functionality (e.g. they do something when clicked) that requires Javascript (presumably does if so), then use javascript to insert the elements since they're useless without JS. Additionally, if this is the case, make sure there are text replacements for the icons. If ...


1

you can follow the below Steps : Step 1 : In the wp-admin, go to Appearance -> Menus,put the class on the menu item here "CSS Classes (optional)". If you can't see the "CSS Classes (optional)" in the menu item, then there is "Screen Option" in the right top of the screen and there are the options "CSS Class" under "Show advanced menu properties". Step 2: ...


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.



Top 50 recent answers are included