Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #709916

    Hi,

    i’m desperately trying to keep the current page highlighted on the main menu when I go into an individual woocommerce product page. So for example, on the following page I want the “OWN” in the main menu to be highlighted…

    Any help would be greatly appreciated!

    Cheers,
    Thomas

    #710581

    Hey thomashutton,

    Try to add this code in Quick CSS (located in Enfold > General Styling):

    .menu-item-mega-parent > a .avia-menu-text {
        color: yellow;
    }

    Just change the color value as you see fit. Hope this helps :)

    Best regards,
    Nikko

    #711481

    Thanks Nikko, that seems to work for the “Own” menu heading but when i’m on of the “Rent” product pages, or “Used” pages “Own” is still highlighted rather than “Rent” or “Own” respectively?

    #712058

    Hi,

    Please remove the code Nikko posted above and post us your login credentials (in the “private data” field), so we can take a look at your backend.

    Login credentials include:

    • The URL to the login screen.
    • A valid username (with full administration capabilities).
    • As well as a password for that username.
    • permission to deactivate plugins if necessary.

    Best regards,
    Yigit

    #712697

    Thanks Yigit, please find the details in the private content area… Big thank you… Thomas

    #713428

    Hi,

    Did you use “own”, “rent” and “used” as category of those products? If you did, you can add this in the functions.php file.

    add_filter( 'body_class', function( $classes ) {
    	global $product;
    	$terms = wp_get_post_terms( $product->id, 'product_cat', array( 'fields' => 'slugs' ) );
    
    	switch (true) {
    	    case in_array( 'own', $terms ):
    	        $classes = array_merge( $classes, array( 'own' ) );
    	        break;
    	    case in_array( 'rent', $terms ):
    	        $classes = array_merge( $classes, array( 'rent' ) );
    	        break;
    	    case in_array( 'used', $terms ):
    	        $classes = array_merge( $classes, array( 'used' ) );
    	        break;
    	    default:
            	$classes = $classes;
    	}
    	return $classes;
    });

    And then use this css codes.

    .own #menu-item-735 > a .avia-menu-text {
        color: green;
    }
    
    .rent #menu-item-40 > a .avia-menu-text {
        color: red;
    }
    
    .used #menu-item-69 > a .avia-menu-text {
        color: blue;
    }

    Best regards,
    Ismael

    #714203

    Thanks for this Ismael, yes the stores on those pages are organised according to the categories.

    The PHP code doesn’t seem to be working though… the first and last line are showing as having errors, do I need to bracket them in some other code?

    #714235

    Hi,

    We added the code in the functions.php file and it’s not causing any errors. However, the code is not working in your installation. Please post the ftp details here so that we can inspect it further.

    Best regards,
    Ismael

    #716922

    Hi,

    weirdly I added the ftp details in a private message a while ago but just checking now it doesn’t seem to have gone through?! Here it is again…

    Thanks, Thomas

    #718108

    Hi,

    Thank you for the info. We modified the code in the functions.php file. Please remove browser cache or hard refresh before checking the page product page.

    // http://weflexcarsales.com/own-cat/new-toyota-prius-active/

    Best regards,
    Ismael

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.