WordPress.org

Ready to get started?Download WordPress

Forums

adding multisite language switcher to my thesis header (6 posts)

  1. cielle
    Member
    Posted 1 year ago #

    Hello, and thank you for a WONDERFUL Plugin..

    I am currently using this code to add the language switcher to my nav menu and it is working great... :

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    /* adding multisite language switcher to main menu */
    function my_custom_menu_item( $items, $args ) {
        if ( class_exists( 'MslsOutput' ) && 'primary' == $args->theme_location ) {
            $obj = new MslsOutput;
            $arr = $obj->get( 2 );
            if ( !empty( $arr ) ) {
                $items .= '
    <li>' . implode( '</li>
    <li>', $arr ) . '</li>
    ';
            }
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );

    I would like to be able to add it to other areas using thesis hooks ...

    can you please tell me the code to use? i do apologise for any inconvenience, I tried changing the 'wp_nav_menu_items' with for example 'thesis_hook_header' but it didn't appear to work...

    thank you!

  2. realloc
    Member
    Posted 1 year ago #

    Sorry for the delay ... I saw your post this morning in my RSS feed (?).

    I'm not sure if I got it completely but you can get the output with the function get_the_msls(). But it depends on the hook how you should design a filter or an action.

    Could you give me more information?

  3. cielle
    Member
    Posted 1 year ago #

    Hi realloc, sorry, i am not a php expert!

    I don't know what more information you need, usually when i add a function to my thesis wordpress i do it like so...

    function mslw() {
    add the code here...
    }
    add_action('thesis_header', 'mslw');

    So i am not sure how i would add the language switcher in this way to my header?

    I hope this is clearer now??

    thank you so much for your time!

  4. realloc
    Member
    Posted 1 year ago #

    So something like this could work

    add_action( 'thesis_header', 'the_msls' );

    Cheers,
    Dennis.

  5. cielle
    Member
    Posted 1 year ago #

    thanks Dennis, no, that does not seem to work, it is the code in the middle ( where i say "add code here" that i need help with... )

    thanks for your time, i do appreciate it, I don't mean to add to your already busy workload!

  6. realloc
    Member
    Posted 1 year ago #

    Strange. This line should be more or less the same like ...

    function mslw() {
        the_msls();
    }
    add_action( 'thesis_header', 'mslw' );

    or

    function mslw() {
        echo get_the_msls();
    }
    add_action( 'thesis_header', 'mslw' );

    Are you sure that 'thesis-header' is the right hook? Please have a look at this post for example.

Topic Closed

This topic has been closed to new replies.

About this Topic