Hi,
I have the following requirement: I have a page with a few different menus, different logos and different menu colors.
To use different menus I use the plugin Zen Menu Logic. For displaying different logos I added this script in the functions.php
add_filter('avf_logo','av_change_logo');
function av_change_logo($logo)
{
if(is_page(11774) || is_page(9711) || is_page(9713) )
{
$logo = "/wp-content/uploads/2017/06/logo_whathever.png";
}
}
What I have no solution for is the following:
I need to change the color of the main-menu (and only that) depending on what page I’m on. I know how to get the page_id() – but how to assign different styles to the main-menu including the dropdowns and hovers – because I need this for 3 to 4 different colors…
Also I need to change the menu/logo/color on blog-category pages and blog-posts depending on the category…I already tried to add this to the filter in the functions.php like this:
if(is_single(11913) && is_category(465) )
to check if it is a post AND in a specific category…
Hey Robert,
To change the color of the menu I recommend using your IF statement to assign the css for the menu colors with !important; I also recommend removing any menu colors from your style.css or Quick CSS field and using those colors in your ELSE statement.
Here is an example of adding your menu css in the head conditionally:
add_action('wp_head', 'change_menu_color');
function change_menu_color() {
if (is_page(array(17, 19, 1, 11))) { ?>
<style>
/* your css here */
</style> <?php
}
}
just do this for each of your colors.
Best regards,
Mike