Tag Info

New answers tagged

0

I'm not 100% sure if I get you right, but maybe this will solve your problem: add_filter( 'wp_nav_menu_items', 'fx_user_menu', 10, 2 ); function fx_user_menu( $items, $args ) { if ($args->theme_location == 'primary') { $myposts = get_posts( array( 'category' => <YOUR CATEGORY ID GOES HERE>, 'posts_per_page' ...


0

You could use Javascript to move the Submenu items where ever you please. <script> jQuery(document).ready(function() { (function ($) { $('.sub-menu-new').after( $('.main-menu') ); })(jQuery); }); </script> OR... You could take a look at the wp_nav_menu_objects filter hook It could allow you to ...


0

If you're not actually using a custom nav menu, why are you not just outputting wp_page_menu() directly? Problem As-implemented, your walker will never be executed (or, more accurately, you can't control whether or not it is executed), because you're not passing 'theme_location' (correct usage) or 'menu' (sub-optimal usage) to the args array. Here's how ...


1

I figured out how to pull all the Category / Brand combinations with a single MySQL query. Then, I loop through the combinations to build an array of all Categories and their associated brands. Here's the query: $brands_categories = $wpdb->get_results(" SELECT te2.term_id AS category_id, te2.slug AS category_slug, te2.name AS category_name, ...


0

Ifigured it out myself, thanks to reading this: http://code.tutsplus.com/tutorials/understanding-the-walker-class--wp-25401 I created a custom walker: class Child_Wrap extends Walker_Nav_Menu { function end_el(&$output, $item, $depth) { $indent = str_repeat("\t", $depth); $output .= "$indent</div></li>\n"; } } ...


0

http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items You can use this example to get started: // Get the nav menu based on $menu_name (same as 'theme_location' or 'menu' arg to wp_nav_menu) // This code based on wp_nav_menu's code to get Menu ID from menu slug $menu_name = 'custom_menu_slug'; if ( ( $locations = ...


2

First of all you need a way to get terms form a taxonomy (brand) related to posts associated to another taxonomy (category). The fastest "core" way to do it is: get a list of all categories for each category get related products loop products and retrieve related brands This workflow require a nested loop, and also a + b + 1 queries, where a is the ...


0

There's surely a more straight to the point way of doing this, but consider the following: 1) You build the top level for your menu by filling an array with your site's categories: http://codex.wordpress.org/Function_Reference/get_categories 2) You run a foreach on the array, and go grab posts from each category, and save their "brand" taxonomy in an array ...


1

You need to assign the menu to the particular theme option from the admin end, Orelse use this code, wp_nav_menu( array( 'menu' => 'second-menu' ) ); Instead of, wp_nav_menu( array( 'theme_location' => 'second-menu' ) ); This will work.


0

These don't match: register_nav_menus( array( 'second-menu' => __( 'Second Menu' ) ) ); and wp_nav_menu( array( 'theme_location' => 'producten-menu' ) ) Your 'theme_location' must match the slug passed to the register_nav_menus() array: register_nav_menus( array( $slug => $title ) ); gets called as: wp_nav_menu( array( ...


0

Under "Settings" -> "Reading" in the wp-admin you (or other users) can set which page should be used as the home page.


2

When you're under Appearance > Menus, there should be a link in the top right-hand corner of the screen titled "Screen Options." Check "Categories" or anything else in order to add other items to the menus. This is useful in other pages of the dashboard as well, because some important items (post revisions for example) are hidden there.


0

your problem is in your use 'menu_class' and 'items_wrap' not synchronized. You can edit : wp_nav_menu( array( 'theme_location' => 'header-menu', 'container' => '', 'echo' => '0', 'menu_class' => 'nav-menu horiz-menu container sixteen columns', 'items_wrap' => ...


1

The question is light on detail but I'd lean toward a custom Walker: class My_Page_Walker extends Walker_Page { function end_el( &$output, $page, $depth = 0, $args = array() ) { $output .= '<span>After the Anchor</span></li>'; } } $args = array( 'walker' => new My_Page_Walker ); wp_list_pages( $args ); That should ...


1

This ended up doing the trick. function auto_hashtag( $menu_item ) { if ( ! is_admin() && $menu_item->post_parent > 0) { // url $url = $menu_item->url; $menu_item->url = preg_replace('!/([^/]+)/$!', "/#\\1", $url); } return $menu_item; } add_filter( 'wp_setup_nav_menu_item', 'auto_hashtag' );


0

What you are trying to do seems like a bad idea; the # symbol is used at the end of a URL to denote an anchor position for the website to scroll to. Take for example this very page with this link: Add # to submenu URLs automatically When clicked, it moved the screen down to the <div> tag with an id of post-form. In the example you give ...


2

These fields are created in Walker_Nav_Menu_Edit::start_el(). To change or to remove them, create a custom walker (example for another walker) that extends Walker_Nav_Menu_Edit and uses other or less fields. Then filter wp_edit_nav_menu_walker and return the class name of your walker. Pseudo-code: class Walker_Nav_Menu_Edit_Simple extends ...


-1

Code is here: Wordpress chained categories I write the same code for categories. You can edit for your needs. I used the that js plugin: http://www.appelsiini.net/projects/chained


0

Here's a function I use to add a first / last class to wp_nav_menu() items: function add_first_and_last($items) { $items[1]->classes[] = 'first'; $items[count($items)]->classes[] = 'last'; return $items; } add_filter('wp_nav_menu_objects', 'add_first_and_last');


0

After several iterations with the wp_update_nav_menu_item function (see below) i just looked through the code to see what WP does itself in case an admin clicks on the "Delete" link of a menu entry. Turns out that it simply calls wp_delete_post for that specific menu entry and that is that. Nothing else, nothing fancy. So in case you want to delete a menu ...


0

It seems to me that you could handle this through CSS in that you could hide the lower level menu options by default, and then choose to show them if they have certain classes above them. On this Codex page, you can see the menu classes (and on your page itself). So for the "second level" you described, assuming the first level menu is level 1 - not 0. ul ...


1

I think I got the answer: function my_nav_menu( $args = array() ) { $echo = isset( $args['echo'] ) ? (bool)( $args['echo'] ) : true; $args['echo'] = false; add_filter( 'wp_nav_menu_objects' , 'my_filter_nav_menu' , 100 , 2 ); $menu = wp_nav_menu( $args ); remove_filter( 'wp_nav_menu_objects' , 'my_filter_nav_menu' , 100, 2 ); ...


0

Given that the markup of your menu does not seems to generating all of the classes I'd expect to see, I'll guess at the problem. Your theme is using a custom Walker Or something-- theme or plugin-- has added a filter to (probably) wp_nav_menu_css. Though there are other filters that could be used. To fix it, or try to, make sure your theme does not ...


0

I think the wholee problem is your trying to use the default walker, but by declaring it in the walker field your telling wordpress your trying to load a custom walker, the wp walker is loaded by default if left empty. two options: 1/ change 'walker' => new Walker_Nav_Menu() to 'walker' => '' as its called by default. 2/ edit declaration to a new name ...


0

For me what worked was this: <?php wp_nav_menu( array( 'container' => '', 'items_wrap' => '%3$s' ) ); ?> Hope it helps.


1

show_home isn't working for you because there is no show_home argument on wp_nav_menu. You will need to add it using the menu editor in the admin panel, most likely as a custom link. These are the valid arguments: $defaults = array( 'theme_location' => '', 'menu' => '', 'container' => 'div', 'container_class' ...


1

To be honest I think you can just use some custom css to get the job done. Wordpress gives the homepage a custom body class of home. so if we use that and dig down in the css to the first menu and move it over into view you should be good. .home .menu > li > ul { left: 0; } and to get the hover state on the 'Data' link just use .home #header .menu ...


0

I've had this happen to me in the past at least 3-4 times but I don't really know what caused it. More often than not I was able to solve it by deleting the menu I was having problems with and creating a new one.


-2

You need to save the menu name first when you create it. After which you can add menu items to the menu. There may be issues with a conflict on the name of the menu. The database updates with WordPress 3.8.1 may have not update. Try re-updating Wordpress, if that doesn't work, and it isn't an issue with plugins then go to the next paragraph. Also for me ...


1

There is a fix coming up for the same, here is the ticket: https://core.trac.wordpress.org/changeset/27755 In case you need it urgently, you can give this a try Original Answer by @goldenapples, here is the link: Dynamic navigation for custom post type (pages) function wp_list_post_types( $args ) { $defaults = array( 'numberposts' => -1, ...


0

You could either extend the Walker_Nav_Menu walker class (i.e., the start_el function is sufficient, as already mentioned). Or you could hook in when the original output (i.e., the category) has been created. That would be the walker_nav_menu_start_el hook. For instance like so: function wpdev_139801_start_el( $item_output, $item ) { if ( isset( ...


0

In addition to @Rarsts answer, once you've created a custom post type with archive like this example: //* Create product custom post type add_action( 'init', 'register_product_custom_post_type' ); function register_product_custom_post_type() { register_post_type( 'product', array( 'labels' => array( 'name' => __( ...


0

What you are looking for is custom post type archive. First you should make sure that your CPT is registered to have archive at all. Unfortunately natively WP doesn't add CPT archives as available to be included in menus. The simplest solution is just to add custom link to it. There are also multiple snippets and plugins to address this floating around, ...


0

To center the menu just edit this css code : .main-navigation ul.nav-menu, .main-navigation div.nav-menu > ul { text-align: left; } to : .main-navigation ul.nav-menu, .main-navigation div.nav-menu > ul { text-align: center; }


0

Problem was the theme that we purchase didn't upload the plugins and other Java Script files properly So it was giving an error. Going through theme installation document helped me.



Top 50 recent answers are included