better-studio / better-amp

Full Google AMP support for WordPress with custom themes and customizations
https://betterstudio.com/wp-plugins/better-amp/
GNU General Public License v2.0
19 stars 19 forks source link

Sidebar not working with my code #68

Open benfiratkaya opened 5 years ago

benfiratkaya commented 5 years ago

Hello i use this code in functions.php

  function benfiratkaya_add_search_form($items, $args) {
    if ($args->theme_location == 'primary') {
      $searchForm = get_search_form(false);
      $items      .= $searchForm;
      return $items;
    }
  }
  add_filter('wp_nav_menu_items', 'benfiratkaya_add_search_form', 10, 2);

if use this code not showing sidebar menu items.

benfiratkaya commented 5 years ago

I fixed with this code:

  function benfiratkaya_add_search_form($items, $args) {
    if ($args->theme_location == 'primary' && !is_better_amp()) {
      $searchForm = get_search_form(false);
      $items      .= $searchForm;
    }
    return $items;
  }
  add_filter('wp_nav_menu_items', 'benfiratkaya_add_search_form', 10, 2);

i checking with 'is_better_amp()' function