How to create a category menu?

You have to register menu’s in your theme’s functions.php unless you only wish to use them in widgetised areas. As an example:- <?php register_nav_menu(‘main’, ‘Main Navigation Menu’); ?> Then you have to call that menu into your template file where you wish it to be displayed, so for example, in the header (header.php):- <?php wp_nav_menu( … Read more

WordPress – site with 2 stylesheets and more…

Create WordPress template with name College & Corporate respectively. Then add some code in your header.php. Refer is_page_template(). With this method WordPress will identify which template you are using and will apply CSS related to it. You can use Default template for rest of the pages.

Create a Page via plugin

You can create the page via wp_insert_post( $post, $wp_error );. The array $post contains the data for your page, with the full documentation here. Be sure to receive the ID from your inserted page/post. You can Add the page at the activation of your plugin, but please check first if the option for the page … Read more

Check what “type” a menu item is

Fortunately, there is an easy fix for this. The $item in the Walker delivers Classes, and if the menu item is an archive, you get one of those: menu-item-type-taxonomy (general) menu-item-object-product_cat (product_cat == taxonomyname) as well as $item->type == ‘taxonomy’ $item->object == ‘your_taxonomy’ If you want this logic to work for various Archives (not just … Read more

how to set more than one menus to the same theme location

You can use conditional is_page to define different menu items as you want. if ( is_page( ‘About’ ) ) { wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘menu-left-side-menu’, ‘menu_class’ => ‘menu’, ‘theme_location’ => ‘about-page’ ) ); } elseif ( is_page( ‘Services’ ) ) { wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘menu-left-side-menu’, ‘menu_class’ => ‘menu’, … Read more

Benefits of using Nav Walker?

I would say mostly you see the usage of wp_nav_menu(), which does use wp_get_nav_menu_items(). You can use wp_nav_menu() with the default walker or a custom walker. To be honest I can’t remember the time I did a menu manually, with wp_get_nav_menu_items() or something else, and I tend to be lazy, so this is definitely more … Read more

Indirect modification of overloaded property WP_Post::$classes has no effect

If “line 45” is the one that starts with $element->classes[] in your display_element method then try something like this: public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { $element->has_children = ! empty( $children_elements[ $element->ID ] ); if ( ! isset( $element->classes ) ) { $element->classes = array(); } $element->classes[] = ( … Read more