Progmatically adding menu links to the default (Top) or Footer menu

You have to register the menu location first. Also, I’ve added else statement to be sure $menu_id is defined when menu exists. Otherwise, you’ll see the PHP Notice about undefined variable. WP_DEBUG must be turned on when you develop, that’s why you don’t see the notice. // Initialize name and location $menu_name=”Simple Inventory Menu”; $menu_location … Read more

Functions php shortcode for displaying main menu with no child items

You could set the ‘depth’ argument to 1 in your wp_nav_menu() call to get only top level items, along with the custom menu walker, something like this: return wp_nav_menu( array( ‘menu’ => $name, ‘menu_class’ => ‘footer-menu’, ‘echo’ => false, ‘depth’ => 1, ‘walker’ => new custom_footer_menu_walker ) ); Add the custom menu walker to your … Read more

CTA button that is only visible to some of my users

First define a function to check if user has bought product before. // function to check product bought by user before function has_bought_items( $user_var = 0, $product_ids = 0 ) { global $wpdb; // Based on user ID (registered users) if ( is_numeric( $user_var) ) { $meta_key = ‘_customer_user’; $meta_value = $user_var == 0 ? … Read more

Add custom path to url to specific pages

If you want to change the permalink structure for all Pages (i.e. posts of the page type), you can use the WP_Rewrite::$page_structure property like so: add_action( ‘init’, ‘wpse_382911′ ); function wpse_382911() { global $wp_rewrite; $wp_rewrite->page_structure=”home/%pagename%”; } Don’t forget to flush the rewrite rules — just visit the permalink settings admin page (wp-admin → Settings → … Read more

Add a counter beside menu item label

You can wp_nav_menu_objects filter hook and you can compare your menu label with the condition and append your cart count. check below code. code will go active theme functions.php file. tested and works. function modify_cart_label_in_nav_menu_objects( $items, $args ) { if($args->theme_location == ‘primary’){ foreach ( $items as $key => $item ) { if ( $item->title == … Read more

Menu separator appearing on next line

Try doing .navbar-default ul, .navbar-default li { display: flex; list-style-type: none; list-style-image: none; padding: 0; } You may need to style the spacing a bit differently but this should make them display in one line