• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Add custom filter to a secondary nav

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Add custom filter to a secondary nav

This topic is: resolved

Tagged: wpml

  • This topic has 10 replies, 3 voices, and was last updated 10 years ago by Ebelanger.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • May 11, 2015 at 8:43 am #151712
    Ebelanger
    Member

    Hello,

    I'm trying to show the inactive language in my secondary nav menu with wpml.

    So far I'm able to output correctly my custom inactive to my genesis header.

    But it doesn't get outputed in my secondary nav menu.

    Anyone can help me?

    May 11, 2015 at 9:11 am #151721
    Johann Kratzik
    Member

    In short, this task requires 2 steps:

    1. Creating a widget area to include into the menu
    2. Filtering wp_nav_menu_items to include this widget area into the navigation menu. Tutorial at http://www.wpbeginner.com/wp-themes/how-to-add-custom-items-to-specific-wordpress-menus

    Let me know if this helps or if you need a working example.


    Offering customization work for FREE – Read more

    May 11, 2015 at 9:28 am #151725
    Ebelanger
    Member

    Hello Johann,

    Thank you very much for the information.

    I'll look into it.

    So far, I already have a secondary in the above_header hook. Do I need to create a new one for my custon filter?

    Or the step one, you talk about is to create the space for the secondary menu at the beginning?

    Thanks again for your time.

    May 11, 2015 at 9:55 am #151726
    Johann Kratzik
    Member

    You can keep the menu in this hook, the filter only changes the menu output and will add the widget area to the menu items.

    Step 1 is to create an additional widget area. You can put the WPML language switcher into this widget area in the backend.

    However there will be a third step, CSS tweaks. Probably you want the switcher floating to the right side, you want to hide the active language. And maybe adjust the look of the WPML widget.


    Offering customization work for FREE – Read more

    May 11, 2015 at 10:05 am #151727
    Ebelanger
    Member

    Hi Johann,

    I was able to move the menu in the secondary menu and the primary. I just 'display:none' on my primary menu for that item.

    Now my question, I have is:

    How can I change the order in which i want the language to show. Now it's showed at the beginning of my secondary menu. I would like to appear at the end.

    I'm pretty sure it's just the order number to change but where?

    Thanks again. You helped me a lot.

    Yours,

    May 11, 2015 at 10:14 am #151728
    Johann Kratzik
    Member

    In the HTML source code search for the id in the

  • item that holds the widget. Then make this item float: right in stlye.css

    Offering customization work for FREE – Read more

May 11, 2015 at 1:23 pm #151757
Johann Kratzik
Member

Here is the full example code. I have tested and it should work in all Genesis child themes:


//* Registering the widget area to display in the secondary navigation
genesis_register_widget_area(
    array(
        'id'               => 'nav-widget',
        'name'             => 'Navigation widget',
        'before_widget'    => '<li class="menu-item wpml-nav">',
        'after_widget'     => '</li>'
    )
);

//* Filtering the secondary navigation to insert the widget area
add_filter( 'wp_nav_menu_items', 'jk_menu_widget', 10, 2 );
function jk_menu_widget ( $items, $args ) {
    if ( $args->theme_location == 'secondary' && is_active_sidebar( 'nav-widget' ) ) {
        ob_start();
        dynamic_sidebar( 'nav-widget' );
        $nav_widget = ob_get_clean();
        $items .= $nav_widget;
    }
    return $items;
}

Offering customization work for FREE – Read more

May 11, 2015 at 1:47 pm #151764
Ebelanger
Member

Thank you very much Johann.

I give it a try.

So far, I'm good with what I have. I'll try later on to move it to the right side of my menu. At least it works perfectly.

Thank you very much for you time and knowledge.

May 11, 2015 at 2:16 pm #151774
Johann Kratzik
Member

Welcome! If the solution works, please mark the thread as "resolved" so it can be closed. If you still need help post it here.


Offering customization work for FREE – Read more

May 11, 2015 at 2:48 pm #151777
Brad Dalton
Participant

This is the code you can use

<script src="https://gist.github.com/braddalton/428545d1431fcaf8152b.js"></script>


Tutorials for StudioPress Themes.

May 12, 2015 at 6:51 am #151838
Ebelanger
Member

Thank you guys for your help!

  • Author
    Posts
  • Viewing 11 posts - 1 through 11 (of 11 total)
    • The topic ‘Add custom filter to a secondary nav’ is closed to new replies.

    CTA

    Ready to get started? Create a site or shop for themes.

    Create a site with WP EngineShop for Themes

    Footer

    StudioPress

    © 2025 WPEngine, Inc.

    Products
    • Create a Site with WP Engine
    • Shop for Themes
    • Theme Features
    • Get Started
    • Showcase
    Company
    • Brand Assets
    • Terms of Service
    • Accptable Usse Policy
    • Privacy Policy
    • Refund Policy
    • Contact Us
    Community
    • Find Developers
    • Forums
    • Facebook Group
    • #GenesisWP
    • Showcase
    Resources
    • StudioPress Blog
    • Help & Documentation
    • FAQs
    • Code Snippets
    • Affiliates
    Connect
    • StudioPress Live
    • StudioPress FM
    • Facebook
    • Twitter
    • Dribbble