搜索不会为活动或产品提取标题或精选图片

时间:2015-04-18 01:30:01

标签: wordpress events search woocommerce

我们在网站上使用Wordpress 4.1.1,WooCommerce和活动日历:

http://www.journeyfilm.com/

以下是搜索结果页面中显示的内容: http://www.journeyfilm.com/?s=long

第一个是帖子,它有效,第二个是事件,第三个是产品(它们都不起作用)。

<div class="search_page">
    <article class="post-1198 post type-post status-publish format-video has-post-thumbnail hentry category-adventures category-blogs" id="post-1198">
        <header class="entry-header">

                            <a rel="bookmark" href="http://www.journeyfilm.com/the-long-haul-screenings-at-the-trail-running-film-festival/">

                    <img width="110" height="165" alt="-The Long Haul Poster-TRFF Label" class="attachment-300x165 wp-post-image" src="http://www.journeyfilm.com/wp-content/uploads/2015/03/The-Long-Haul-Poster-TRFF-Label-200x300.jpg">                      <h1 class="entry-title-search">The Long Haul Screenings at The Trail Running Film Festival</h1>
                        <div class="entry-meta-search">
                        <span class="posted-on"><time datetime="2015-03-05T17:42:14+00:00" class="entry-date published">March 5, 2015</time><time datetime="2015-03-05T17:50:05+00:00" class="updated">March 5, 2015</time></span>                  </div>
                </a>

        </header>
</article>
</div>
<div class="search_page">
<article id="post-1066" class="post-1066 tribe_events type-tribe_events status-publish has-post-thumbnail hentry cat_events cat_thelonghaulscreenings">
</div>
<div class="search_page">
<article id="post-876" class="post-876 product type-product status-publish has-post-thumbnail featured shipping-taxable purchasable product-type-variable product-cat-blu-ray product-cat-download product-cat-dvd product-cat-finishingkick product-cat-hiking-sport product-cat-on-demand product-cat-rental product-cat-running product-cat-screenings instock">
<header class="entry-header"> </header>
</article>
</div>

以下是我们的Search.php文件的代码:

<?php get_header(); ?>


    <section id="primary" class="content-area search "><!--.w-sidebar-->
        <main id="main" class="site-main" role="main">
        <h1 class="search-title">Search Results: <?php echo the_search_query()?></h1>
        <?php /*

            if(isset($_GET['post_type'])) {
                $type = $_GET['post_type'];
                $args = array( 'post_type' => $type );
                $args = array_merge( $args, $wp_query->query );
            query_posts( $args );    
            }*/
        ?>
        <?php if ( have_posts() ) : ?>
            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'content', 'search' ); ?>
            <?php endwhile; ?>

            <div class="clear"><div><?php undiscovered_paging_nav(); ?>
        <?php else : ?>
            <?php get_template_part( 'content', 'none' ); ?>
        <?php endif; ?>

        </main>
    </section><!-- .primary -search.php -->
    <div class="sidebar-right">
        <?php //if ( ! dynamic_sidebar( 'sidebar-right' ) ) : ?>

        <?php// endif; ?>
    </div><!-- .sidebar-right -search.php -->
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

我们无法弄清楚他们为什么不出现。任何帮助,将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)

根据您提供的网址//www.journeyfilm.com/?s=long,您的帖子类型块永远不会运行,因为没有post_type查询字符串参数设置。

 if(isset($_GET['post_type'])) {
            $type = $_GET['post_type'];
            $args = array( 'post_type' => $type );
            $args = array_merge( $args, $wp_query->query );
        query_posts( $args );    
        }