Tagged: Sticky Menu
- This topic has 7 replies, 2 voices, and was last updated 9 years, 11 months ago by Sakin.
-
AuthorPosts
-
January 3, 2015 at 6:36 am #49522John UMember
Hello – I love the way the #masthead is sticky and stays at the top when scrolling down. Is there any way to do this with the #secondary-menu?
I have tried some plugins – Sticky Menu and MyStickyMenu but they both have problems with Chrome vs FireFox and different size browswers which #masthead doesn’t have.
It looks like #secondary-menu is inside the #main-wrapper. Do I have to move it into the masthead or create a new widget?
Here’s the site: chezjillchocolates.com
January 3, 2015 at 10:10 am #49526SakinKeymaster@John U: To move the secondary menu position, first you need to build child theme, For child theme ready this http://catchthemes.com/blog/create-child-theme-wordpress/ and then you need to add the following code in your child theme functions.php file:
// Removing the Default Action Hook function unhook_adventurous_functions() { //remove default secondary menu add_action( 'adventurous_before_main', 'adventurous_secondary_menu', 10 ); } add_action( 'init', 'unhook_adventurous_functions' ); // Add Secondary menu after hgroup wrpa add_action( 'adventurous_after_hgroup_wrap', 'adventurous_secondary_menu', 5 );
January 4, 2015 at 11:19 pm #49568John UMemberI made the Child Theme – but the changes don’t work.
Here is my child theme’s functions.php file:
<?php // Removing the Default Action Hook function unhook_adventurous_functions() { //remove default secondary menu add_action( 'adventurous_before_main', 'adventurous_secondary_menu', 10 ); } add_action( 'init', 'unhook_adventurous_functions' ); // Add Secondary menu after hgroup wrpa add_action( 'adventurous_after_hgroup_wrap', 'adventurous_secondary_menu', 5 );
I believe both the parent and child theme’s functions.php files are called – if so, how could the child theme overwrite the parent?
I tried adding CSS to fix the 2nd Nav Bar but no luck.
Source Code still shows the 2nd Nav Bar inside the Main Wrapper.
Any suggestions?
I also tried this for child theme’s functions.php
<?php // Exit if accessed directly if ( !defined( 'ABSPATH' ) ) exit; // BEGIN ENQUEUE PARENT ACTION if ( !function_exists( 'chld_thm_cfg_parent_css' ) ): function chld_thm_cfg_parent_css() { wp_enqueue_style( 'chld_thm_cfg_parent', get_template_directory_uri() . '/style.css' ); } endif; add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css' ); // END ENQUEUE PARENT ACTION // Removing the Default Action Hook function unhook_adventurous_functions() { //remove default secondary menu add_action( 'adventurous_before_main', 'adventurous_secondary_menu', 10 ); } add_action( 'init', 'unhook_adventurous_functions' ); // Add Secondary menu after hgroup wrpa add_action( 'adventurous_after_hgroup_wrap', 'adventurous_secondary_menu', 5 );
but no luck.
January 5, 2015 at 10:32 pm #49591SakinKeymaster@John U: Sorry I gave to wrong code. I forgot to remove the actions. So the code will be as below:
// Removing the Default Action Hook function unhook_adventurous_functions() { //remove default secondary menu remove_action( 'adventurous_before_main', 'adventurous_secondary_menu', 10 ); } add_action( 'init', 'unhook_adventurous_functions' ); // Add Secondary menu after hgroup wrpa add_action( 'adventurous_after_hgroup_wrap', 'adventurous_secondary_menu', 5 );
January 8, 2015 at 4:18 am #49760John UMembernope – not working – screen goes white on Live Preview – any suggestions?
Have you actually tested this code on your end?
January 8, 2015 at 4:23 am #49761John UMemberWhat is the proper code to enqueue the CSS style page? This theme has a CSS folder with other styles in it.
Here is my functions.php file including the code for the Sticky 2nd Nav Menu
<?php /** * Adventurous Pro Child Theme functions and definitions */ /** * Enqueue the parent theme style.css because @import doesn't work in ie8 */ function adventurous-pro_enqueue_scripts_styles() { wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'adventurous-pro_enqueue_scripts_styles' ); // Removing the Default Action Hook function unhook_adventurous_functions() { //remove default secondary menu add_action( 'adventurous_before_main', 'adventurous_secondary_menu', 10 ); } add_action( 'init', 'unhook_adventurous_functions' ); // Add Secondary menu after hgroup wrpa add_action( 'adventurous_after_hgroup_wrap', 'adventurous_secondary_menu', 5 );
Questions: How to enqueue the other styles is the CSS folder?
January 8, 2015 at 4:44 pm #49771SakinKeymaster@John U: Other CSS are automatically added and the parent style.css is imported in style.css of child theme. You will see the following CSS in your child theme style.css
/* =Import Adventurous Pro CSS -------------------------------------------------------------- */ @import url("../adventurous-pro/style.css");
So, you don’t need to add adventurous-pro_enqueue_scripts_styles() function in your child theme functions.php file. Also in your //remove default secondary menu, you have done add_action and it should be as remove_action. Your child theme functions.php file should be as.
January 9, 2015 at 9:32 am #49815 -
AuthorPosts
- The topic ‘Sticky 2nd Nav Menu’ is closed to new replies.