I am using a wordpress theme and i wanted to change the navigation menu to a one-page navigation menu. I already made everything work except when i am using a mobile the menu does not close when i click the menu-items. All the menu links start with #. I am using a child-theme and want to add a function to the function.php file that closes the window when menu-item is clicked.

Here is my function.php file.

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {

    $parent_style = 'PRANAYAMA_YOGA_THEME_VERSION'; // 

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),

Is it possible to do this ?

Thanks in Advance

  • the above mention code is not useful , share the site url. – Techno Deviser Aug 12 at 11:33

I would use javascript (or jQuery) to detect when the menu item is clicked and close the menu.

$( '.menu-item' ).on( 'click', function(e){

    // add a class to target with CSS and close the menu or do animation to close it
} );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.