Google custom search engine appearing in Menu Bar only on home page

Google custom search engine appearing in Menu Bar only on home page, while it is hidden on other pages.
Check this link(It appears out here)

Does not show on this page and many other pages

This is the php snippet added

Summary
add_filter( 'wp_nav_menu_items', 'sydney_child_add_top_search_menu', 10, 2 );
    function sydney_child_add_top_search_menu( $items, $args ) {
        if ($args->theme_location == 'primary') {
          $items .= '<li class="top-search-menu">'.get_search_form(false).'</li>';
        return $items;
    	}
    }

This is the css added

Summary
@media only screen and (min-width: 1025px) {
  .site-header .col-md-4 {
    width: 21%;
  }
  
  .site-header .col-md-8 {
    width: 79%;
  }        

  .site-header #mainnav {
    float: left;
  }
  
  .top-search-menu {
    width: 200px;
    overflow: visible;
  }
}

@media only screen and (min-width: 1025px) and (max-width: 1160px) {
  div.gsc-control-searchbox-only {
    width: 280px !important;
  }
}
.gsc-search-box-tools .gsc-search-box .gsc-input{
	border:none;
}
.gsib_a {
    padding: 2px 2px 2px 2px;
}
div#gsc-iw-id1.gsc-input-box{
width:180px;
border:0;
}
button.gsc-search-button{
		height:33px;
		width:30px;  
		float:left;    
		margin-left:-17px;  
}
.gsc-search-button-v2 svg{
	margin-left: -6px;
  margin-top: 3px;
}
td.gsib_b{
display:none;
}
td.gsc-input{
border:0;
}
td.gsc-search-button{
border:0;
}

Hello there,

I found there’s nothing wrong with the PHP snippet. The Google Search requires some mandatory settings as mentioned in this page:

https://support.google.com/customsearch/answer/4513903?hl=en

Please double check it and ensure everything is properly configured.

Or, to make all a bit easier you could use an additional plugin like WP Google Search. Then you’d need to replace the PHP code snippet with this:

add_filter('wp_nav_menu_items', 'sydney_child_add_top_search_menu', 10, 2);
function sydney_child_add_top_search_menu($items, $args){

	ob_start( );
	the_widget( 'WGS_Widget' );
	$search = ob_get_clean( );

  if ($args->theme_location == 'primary') {
      $items .= '<li class="top-search-menu">'.$search.'</li>';
  }

  return $items;

}

Before doing so, do some proper settings in the plugin administration panel.

Regards,
Kharis