File: /virtual/nagasaki/public_html/shop/wp-content/themes/riffles_ver1.1/search-item.php
<?php
/**
* @package Riffles
* @link http://www.u-hg.com/
* @author RiffleHatch
* @copyright Copyright (c)2014 RiffleHatch
*/
get_header(); ?>
<div class="row clear">
<?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
<div id="primary" class="widget-area col col-2 no-tablet no-mobile" role="complementary">
<?php dynamic_sidebar( 'sidebar-2' ); ?>
</div><!--.widget-area -->
<div class="col col-10 tablet-full mobile-full" itemscope itemtype="http://schema.org/ItemList">
<?php else: ?>
<div class="col col-12 tablet-full mobile-full" itemscope itemtype="http://schema.org/ItemList"><!--.nowidget -->
<?php endif; ?>
<header class="page-header">
<h1 class="page-title" itemprop="name"><?php printf( __( 'Search Results for: %s', 'sanpru' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
</header><!-- .page-header -->
<?php
global $wpdb;
$keyword = get_search_query();
$post_ids_meta = $wpdb->get_col( $wpdb->prepare( "
SELECT DISTINCT post_id FROM {$wpdb->postmeta}
WHERE meta_value LIKE '%s'
", $keyword ) );
$post_ids_post = $wpdb->get_col( $wpdb->prepare( "
SELECT DISTINCT ID FROM {$wpdb->posts}
WHERE post_title LIKE '%s'
OR post_content LIKE '%s'
", $keyword, $keyword ) );
$post_ids = array_merge( $post_ids_meta, $post_ids_post );
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'post__in' => $post_ids,
'category_name' => 'item',
);
$query = new WP_Query( $args );
if ( $query->have_posts() ):
?>
<?php if ( !have_posts() == 0 ) : ?>
<ul class="block itemlist">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part('thumbnail-box'); ?>
<?php endwhile; ?>
</ul>
<div class="col col-12 tablet-full mobile-full">
<?php dynamic_sidebar( 'sidebar-7' ); ?>
<?php riffles_paging_nav(); ?>
</div>
<?php else: ?>
<div class="noresult">
<p><?php _e('お探しのキーワードに該当する商品は見つかりませんでした。下フォームより別のキーワードで検索してみて下さい。'); ?></p>
<form action="<?php echo esc_url( home_url('/') ); ?>" class="searchform" id="searchform_s" method="get" role="search">
<div>
<input type="search" class="field" name="s" value="<?php esc_attr( get_search_query() ); ?>" id="s_posts" placeholder="<?php _e('商品検索'); ?>">
<input type="submit" class="submit" id="searchsubmit_icon" value="検索開始">
</div>
</form>
</div>
<?php endif; ?>
<?php else: ?>
<div class="noresult">
<p><?php _e('お探しのキーワードに該当する商品は見つかりませんでした。下フォームより別のキーワードで検索してみて下さい。'); ?></p>
<form action="<?php echo esc_url( home_url('/') ); ?>" class="searchform" id="searchform_s" method="get" role="search">
<div>
<input type="search" class="field" name="s" value="<?php esc_attr( get_search_query() ); ?>" id="s_posts" placeholder="<?php _e('商品検索'); ?>">
<input type="submit" class="submit" id="searchsubmit_icon" value="検索開始">
</div>
</form>
</div>
<?php endif; ?>
</div><!-- col -->
</div><!-- row -->
<?php get_footer(); ?>