We changed our privacy policy. Read more.

Hot answers tagged

3

You can remove the current icon by css and then you can add your new icon in the .menu-toggle button with background-image. the css is below; .genericon-menu:before{ content: " "; } .main-navigation .menu-toggle{ background-image: url(/*image url*/); background-size: contain; }


3

Follow up on @jmarceli's and @squarecandy's great answers. Here is a solution that allows for: Easier scaling (set an object in the php action) Updates to the correct menu depth when the location checkboxes are changed /** * Limit max menu depth in admin panel */ function limit_admin_menu_depth($hook) { if ($hook != 'nav-menus.php') return; ...


3

You'll find it under Avada Menu Options -> Menu Highlight Label


3

Yes, very much possible and you don't even have to add classes yourself. If you're using wp_nav_menu, Wordpress adds classes for every case the specific nav item is in. I'll name the important classes for Publications (amongst others), based on where you clicked hypothetically: Publications - This is now the selected item, and will get (amongst others) the ...


2

it is stored in the post_name field in database. you can utilize the following code if you are inside a loop: $the_slug = get_post_field( 'post_name' ); or if you are outside the loop: $the_slug = get_post_field( 'post_name', $post_id); where $post_id is the id of the post you want to retrieve from.


2

Can be changed using filter add_filter('wp_get_nav_menu_items', 'add_utm_to_links', 10, 3); function add_utm_to_links($items, $menu, $args) { foreach($items as $item) { if(!empty($item->url)) { $item->url .= strchr($url, '?') === false ? '?' : '&'; $item->url .= 'utm=value'; } } return $...


2

Create a new “Custom Link” menu item where the URL is #latestpost (which will act as a placeholder and target for the code). You can title the item whatever you please. This code will then find that menu item (by looking for the placeholder URL) and then replace it’s URL with that of the latest post’s URL. Since the filter is before the code that adds the ...


2

When using wp_nav_menu() you can exclude the <ul> tag by setting the items_wrap to only include the list items (%3$s), then you can add your own <li> before or after that, and wrap it with <ul> yourself: <ul class="footer-links"> <li> <p>copyright C 2021</p> </li> <?php ...


2

If you have problem with: POST wp-admin/admin-ajax.php 500 in WP define( 'WP_MAX_MEMORY_LIMIT', '512M' ); in wp-config.php max_input_vars = 6000 ; in php.ini and deactivate all plugins and active one by one until you see which plugin is causing problem. (Ps. have the great chance to be the Yoast SEO plugin the problem)


2

I imagine you'll need to create a "form" page and embed the form using a shortcode or block: There are two different ways to embed your forms to a WordPress page: by using the built-in embed wizard through WPForms, or manually, through the Block Editor. Once you have the page ready - you can test it by viewing it directly - you can add a link to ...


2

There's nothing like that with media queries. You need to include the exclusion in your CSS selectors, like this: body:not(.home) .site-header { // etc. } Alternatively, if this is the only CSS in a particular file, you could just not enqueue it on the homepage: add_action( 'wp_enqueue_scripts', function() { if ( ! is_front_page() ) { ...


2

Lookup wp_nav_menu Simply take the HTML you have now and remove the <ul> or whatever elements you are using to list the menu links. If you want it to be dynamic, your theme template will need something similar to the following placed where you want the links to load in place of what you had in your regular HTML site: <?php wp_nav_menu(array( ...


1

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


1

If the only issue is that you want to move an item to the top, there is actually a link to achieve this, once you have clicked to expand on a single menu item


1

I personally use WPFront User Role Editor (free) on both of my sites, after you set menu buttons only to logged in users to be shown they will disappear from visitors view, there are 4 options to choose from. All Users Logged in Users Guest Users Users by Role You can give it a try. Features Create new roles. Edit or rename existing roles. Clone existing ...


1

Try adding this code to your add_action 'init' function. // Let WooCommerce add a new custom endpoint "earnings" for you add_filter( 'woocommerce_get_query_vars', function( $vars ) { $vars['earnings'] = 'earnings'; return $vars; } ); // Add "earnings" to the WooCommerce account menu add_filter( 'woocommerce_account_menu_items', ...


1

You can filter the HTML output with the wp_nav_menu filter. Using preg_replace(): add_action( 'wp_nav_menu', 'wpse_385827_filter_nav_menu' ); function wpse_385827_filter_nav_menu( $menu ) { $menu = preg_replace( '|<li>|', '<li><p>Your inserted content here</li><li>', $menu, ...


1

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 => $...


1

Are you missing a "s" in your variable return $menu_list;? Your array is called $menus_list;


1

In functions.php, change the function magazine_responsive_menu_settings() to the following: function magazine_responsive_menu_settings() { $settings = [ 'mainMenu' => __( 'Menu', 'magazine-pro' ), 'subMenu' => __( 'Submenu', 'magazine-pro' ), 'menuClasses' => [ 'combine' => [ '.nav-...


1

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 ...


1

https://stackoverflow.com/questions/52006212/how-to-get-current-page-menu-item-ancestor-name-wordpress I found a solution through the answers to the above questions. function my_menu_parent($theme_location) { $locations = get_nav_menu_locations(); if ( isset( $locations[ $theme_location ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $...


1

You can extend it, but the class definition and any code that uses it, can't run outside of the admin area. Wrap your class in this conditional: if ( is_admin() ) { ... } If you are trying to use this on the frontend or other non-Admin areas, do not do that. Generally, classes WordPress uses should not be extended, walker classes and WP_Widget are the ...


1

The bug is not in this snippet of code. The problem is with how you call wp_get_nav_menu_array, wherever that happens. The $current_menu is likely something invalid, so wp_get_nav_menu_items returns false, and thus you get the error that you get. You can see in user contributed notes an example of how to get a valid value for $current_menu https://developer....


1

I want the URLs of the nav-items to be replaced with # You can use the nav_menu_link_attributes hook to set the custom href value like so: add_filter( 'nav_menu_link_attributes', function ( $atts, $item, $args ) { if ( 'menu-categorias' === $args->theme_location && 'category' === $item->object ) { $atts['href'] = '#' . ...


1

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 = $...


1

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 ...


1

As you mentioned in the comments, if what works best for you is displaying different header files based on whether a user is logged in or not, this is the best way to achieve it: if( is_user_logged_in() ) : /** This is the name of your second header file. * It assumes the 'header-' and the '.php' portions. * So the following get_header would ...


1

This was a color issue I had to fix through the Astra theme's configuration. It was a bit hidden but I found it: Sorry for not mentioning I was using Astra, but I'm basically kinda abstracted from css and html thanks to it, which aren't my specialties.


1

It's a problem in the generated CSS. This rule is adding a color: #fff to your menu links: .ast-theme-transparent-header .main-header-menu .menu-link, You can overwrite this rule in your CSS file and links will be visible. Check it out (the second CSS block): There you go! :)


Only top voted, non community-wiki answers of a minimum length are eligible