Title: Same question &#8211; trouble with code input
Last modified: August 21, 2016

---

# Same question – trouble with code input

 *  Resolved [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/)
 * Responsive Theme with child theme. [http://www.help-alliance.de](http://help-alliance.de)
   
   Level of PHP is zero. I have tried a number of times to insert the code provided
   into various placs but I keep getting a parse error. Code inserted is `if ( function_exists('
   the_msls' ) ) the_msls()` you mention place this in functions.php. There are 
   two functions.php files. 1 in main dir of theme – code is.
 *     ```
       * WARNING: Please do not edit this file in any way
        *
        * load the theme function files
        */
       require ( get_template_directory() . '/includes/functions.php' );
       require ( get_template_directory() . '/includes/theme-options.php' );
       require ( get_template_directory() . '/includes/post-custom-meta.php' );
       require ( get_template_directory() . '/includes/tha-theme-hooks.php' );
       require ( get_template_directory() . '/includes/hooks.php' );
       require ( get_template_directory() . '/includes/version.php' );
       ```
   
 * 2 in functions.php in theme dir/includes – code relating to main-nav is `/**
 *     ```
       * This feature enables custom-menus support for a theme.
                * @see http://codex.wordpress.org/Function_Reference/register_nav_menus
                */
               register_nav_menus(array(
       			'top-menu'         => __('Top Menu', 'responsive'),
       	        'header-menu'      => __('Header Menu', 'responsive'),
       	        'sub-header-menu'  => __('Sub-Header Menu', 'responsive'),
       			'footer-menu'      => __('Footer Menu', 'responsive')
       		    )
       	    );
   
       		if ( function_exists('get_custom_header')) {
       ```
   
 * Alternative is the header.php file but I still cant get the flags to show in 
   the menu bar itself..
    This is the header.php code:
 *     ```
       <?php get_sidebar('top'); ?>
       				<?php wp_nav_menu(array(
       				    'container'       => 'div',
       						'container_class'	=> 'main-nav',
       						'fallback_cb'	  =>  'responsive_fallback_menu',
       						'theme_location'  => 'header-menu')
       													);
       						?>
       ```
   
 * I have spent a few hours on this trying to figure this out without support but
   I feel I am out of league when php coding is at work.
 * [http://wordpress.org/extend/plugins/multisite-language-switcher/](http://wordpress.org/extend/plugins/multisite-language-switcher/)

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/same-question-trouble-with-code-input/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/same-question-trouble-with-code-input/page/2/?output_format=md)

 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917547)
 * > Same question – trouble with code input
 * Sorry, what are you trying to accomplish? “Same question” isn’t very descriptive.
 *  Thread Starter [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917549)
 * Sorry Jan.
    I hve read alot of the feeds regarding to try and get the multisite
   language swtcher in my main navigation bar. The plugin provides widget that sits
   ontop of nav bar and all the advise I have tried to follow had not helped me.
 * the plug in site oes give advise to how to do this but I am very confused as 
   to where and how to insert this to acheive my goal.
    their support link is [https://github.com/lloc/Multisite-Language-Switcher/wiki](https://github.com/lloc/Multisite-Language-Switcher/wiki).
   My details are above for your veiwing. I really do hope you can help, this is
   the last step in my website. Thansk in advance for any guidance.
 *  Thread Starter [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917551)
 * also to add – this is a post that the theme support provides to get a thier serch
   widget in the main nav area.
    Copy header.php from Responsive to Responsive Child
   Theme and add this in:
 *     ```
       <div id="search-box">
                   <?php get_search_form(); ?>
               </div><!-- end of #search-box -->
       ```
   
 * I thought I could just replace theirs with the code the language swtcher provided
   but keep getting parse errors.
 *  Plugin Author [Dennis Ploetner](https://wordpress.org/support/users/realloc/)
 * (@realloc)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917554)
 * There is a brief description here:
 * [https://github.com/lloc/Multisite-Language-Switcher/wiki/Generate-the-output#manipulate-the-navigation-menu](https://github.com/lloc/Multisite-Language-Switcher/wiki/Generate-the-output#manipulate-the-navigation-menu)
 * It seems that you should use the second _functions.php_ when you want to insert
   some code. The menu in your _header.php_ has the theme_location _header-menu_.
   So I would use something like this
 *     ```
       function my_custom_menu_item( $items, $args ) {
           if ( class_exists( 'MslsOutput' ) && 'header-menu' == $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 );
       ```
   
 * Hope this helps.
 * Cheers,
    Dennis.
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917555)
 * > Sorry Jan.
 * Nothing to be sorry for. 😉
 * > I hve read alot of the feeds regarding to try and get the multisite language
   > swtcher in my main navigation bar.
 * That’s better.
 * You do have a multisite installation right?
 * Try creating a [child theme](http://codex.wordpress.org/Child_Themes) and modify
   your child theme’s copy of the `header.php` file and put these lines in it.
 *     ```
       <!-- Multisite Language Switcher START -->
       <?php if ( function_exists( 'the_msls' ) ) the_msls(); ?>
       <!-- Multisite Language Switcher END -->
       ```
   
 * Then load up your web site and view the HTML. At a minimum you should see those
   comments in the HTML. This will let you test if the function `the_msls()` is 
   even active or not.
 *  Thread Starter [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917563)
 * Hi Dennis – thanks for quick response. Very impressed with plug in and now your
   support.
    I have read the link a number of times now but still not having any
   luck – I keep getting a parse error on the lines I dumped in.
 * You mention both the functions.php and the header.php
    Which one do I place your
   code into – this is what is confusing. I have placed your code as above in the
   2nd functions.php loacted in theme/includes/… This is the code but it did nothing
   to the site. [http://help-alliance.de](http://help-alliance.de)
 *     ```
       * This feature enables custom-menus support for a theme.
                * @see http://codex.wordpress.org/Function_Reference/register_nav_menus
                */
               register_nav_menus(array(
       			'top-menu'         => __('Top Menu', 'responsive'),
       	        'header-menu'      => __('Header Menu', 'responsive'),
       	        'sub-header-menu'  => __('Sub-Header Menu', 'responsive'),
       			'footer-menu'      => __('Footer Menu', 'responsive')
       		    )
       	    );
       function my_custom_menu_item( $items, $args ) {
           if ( class_exists( 'MslsOutput' ) && 'header-menu' == $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 );
   
       		if ( function_exists('get_custom_header')) {</a>
       ```
   
 * _[Please post code & markup between backticks or use the code button. Your posted
   code has now been permanently damaged by the forum’s parser.]_
 *  Thread Starter [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917565)
 * Jan- yes multisite is set-up and the plugin is active and working. That is not
   the issue – The plugin author has stepped (as above) in to assist kindly so thanks
   for your advise though.
 *  Plugin Author [Dennis Ploetner](https://wordpress.org/support/users/realloc/)
 * (@realloc)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917567)
 * Just add the code to the second _functions.php_ and it will add your flags automatically
   to the menu.
 *  Thread Starter [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917570)
 * I dumped your code into 2nd functions.php file adsaved it in my child theme directory.
   
   _This is what comes back to me when going to URL. Fatal error: Cannot redeclare
   responsive\_get\_options() (previously declared in /homepages/29/d125184200/htdocs/
   en/wp-content/themes/coinlogistics\_child/functions.php:38) in /homepages/29/
   d125184200/htdocs/en/wp-content/themes/responsive/includes/functions.php on line
   43 ———————————————————— If I save the edited file in the theme/includes directory
   then nothing happens. ———————————————————– I placed the code as so:
 *     ```
       /**
        * Set a fallback menu that will show a home link.
        */
   
       function responsive_fallback_menu() {
       	$args = array(
       		'depth'       => 0,
       		'sort_column' => 'menu_order, post_title',
       		'menu_class'  => 'menu',
       		'include'     => '',
       		'exclude'     => '',
       		'echo'        => false,
       		'show_home'   => false,
       		'link_before' => '',
       		'link_after'  => ''
       	);
       	$pages = wp_page_menu( $args );
       	$prepend = '<div class="main-nav">';
       	$append = '</div>';
       	$output = $prepend.$pages.$append;
       	echo $output;
       }
   
       function my_custom_menu_item( $items, $args ) {
           if ( class_exists( 'MslsOutput' ) && 'header-menu' == $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 );
       /**
        * This function removes .menu class from custom menus
        * in widgets only and fallback's on default widget lists
        * and assigns new unique class called .menu-widget
        *
        * Marko Heijnen Contribution
        *
        */
       class responsive_widget_menu_class {
       	public function __construct() {
       ```
   
 *  Thread Starter [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917572)
 * OK – thought I had a light bulb moment and removed the MLS widget out and – ALL
   gone now. no flags at all.
 *  Plugin Author [Dennis Ploetner](https://wordpress.org/support/users/realloc/)
 * (@realloc)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917581)
 * Please use just my code:
 *     ```
       function my_custom_menu_item( $items, $args ) {
           if ( class_exists( 'MslsOutput' ) && 'header-menu' == $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 );
       ```
   
 * You copied other code too. _responsive\_get\_options()_ for example…
 *  Thread Starter [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917583)
 * I placed your code EXACTLY at the END of the functions.php file
    in the theme/
   includes folder. **AND NOTHING** changed. do I need to edit your code in anay
   way? Do I remove your widget from the dashboard from all sites on network? I 
   am really stuck here- I do hope we can sort this out. These are the last lines
   on the funcion.php file.
 *     ```
       }
       function my_custom_menu_item( $items, $args ) {
           if ( class_exists( 'MslsOutput' ) && 'header-menu' == $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 );
       add_filter( 'body_class','responsive_add_class' );
       ?>
       ```
   
 *  Thread Starter [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917600)
 * I even tried your code in the header.php at the end of the page but still nothing
   changes.
    I have really run out of options and is frustrated as this seems very
   easy to implemnt but after hours of trying – I am only failing.
 *  Plugin Author [Dennis Ploetner](https://wordpress.org/support/users/realloc/)
 * (@realloc)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917603)
 * My code can just work if you place it in the _functions.php_ and not in the _header.
   php_. You should check if **header-menu** is the right menu or if you have to
   use another menu like **top-menu**, **sub-header-menu** (or **footer-menu**)…
 *  Thread Starter [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * (@jgoldberg2013)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/#post-3917613)
 * Hi Dennis, thanks for being so patient with me but I still can not get switcher
   in the main-nav.
    I have done exactly what you have asked. I have tried it with
   the switcher widget placed in a widget area AND with it out of any widget area.
   Either way still nothing. I know the “main”nav is the class as it says so in 
   firebug html. snapshot of info can be seen at [http://postimg.org/image/8fv8f1zp3/](http://postimg.org/image/8fv8f1zp3/)
   I know zero about php so I am really stuck if you say that your code MUST work
   and it does not.

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/same-question-trouble-with-code-input/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/same-question-trouble-with-code-input/page/2/?output_format=md)

The topic ‘Same question – trouble with code input’ is closed to new replies.

 * ![](https://ps.w.org/multisite-language-switcher/assets/icon-256x256.png?rev=
   2793358)
 * [Multisite Language Switcher](https://wordpress.org/plugins/multisite-language-switcher/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/multisite-language-switcher/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/multisite-language-switcher/)
 * [Active Topics](https://wordpress.org/support/plugin/multisite-language-switcher/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multisite-language-switcher/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multisite-language-switcher/reviews/)

 * 21 replies
 * 3 participants
 * Last reply from: [jgoldberg2013](https://wordpress.org/support/users/jgoldberg2013/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/same-question-trouble-with-code-input/page/2/#post-3917647)
 * Status: resolved