2015-05-14 51 views
1

结果页,我想如果可能的话在以下问题有所帮助:WordPress的自定义布局在搜索与引导

我在创世纪的主题使用的引导电网,并想使用该网格来显示搜索结果。

我创建了下面的代码的search.php:

<?php 
/** 
* Search Results Template File 
*/ 
get_header(); ?> 
    <header> 
     <h1>Search Results: &quot;<?php echo get_search_query(); ?>&quot;</h1> 
     <br> 
    </header> 

<?php if (have_posts()) : // results found?> 
    <?php while (have_posts()) : the_post(); ?> 

<div class="container-fluid"> 

<div class="row"> 

<div class="col-md-3 col-sm-6 col-xs-12"> 
<div class="gr-infos-container-cliente"> 
<div class="gr-promo-do-cliente"><?php the_field('tipo_de_promo');?></div> 
<div class="gr-img-cliente"><a href="<?php the_permalink();?>" title="<?php the_title();?>"><img src="<?php echo get_field('foto_cliente_miniatura');?>" alt="" class="img-responsive center-block"></a></div> 
<div class="gr-nome-cliente"><a href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?></a></div> 
<div class="gr-tagline-cliente"><?php the_field('tagline_do_anunciante');?></div> 
<div class="gr-bairro-do-cliente"><i class="cliente fa fa-map-marker"></i><?php the_field('bairro_do_cliente');?></div> 
</div> 
</div> 

</div> <!-- Row --> 

</div> <!-- Container --> 

<?php endwhile; ?> 

<?php else : // no results?> 
    <article> 
     <h1>No Results Found.</h1> 
    </article> 
<?php endif; ?> 
<?php get_footer(); ?> 

genesis(); 

但在搜索结果中,内容是对准一个在另一个上面,而不是在选择网格。

您可以给我的任何提示?

我非常感谢任何帮助!

+0

的代码可以附上你的,你看有什么截图? – Ajith

+0

感谢您的快速响应!截图的链接是:[链接] http://res.cloudinary.com/guiario/image/upload/v1431601095/snap-site_zmjkkd.jpg [/ link] – Artmaug

+0

是这个手机视图?或者你需要连续2/3项目,不能得到它的工作? – Ajith

回答

1

这是因为你的'row'div在while循环中,导致它产生多个'row'div而不是一个。

要解决这个问题,您需要将while循环放置在'row'div内。

尝试波纹管

<?php 
/** 
* Search Results Template File 
*/ 
get_header(); ?> 
<header> 
    <h1>Search Results: &quot;<?php echo get_search_query(); ?>&quot;</h1> 
    <br> 
</header> 

<?php if (have_posts()) : // results found?> 
<div class="container-fluid"> 
    <div class="row"> 
    <?php while (have_posts()) : the_post(); ?> 
     <div class="col-md-3 col-sm-6 col-xs-12"> 
      <div class="gr-infos-container-cliente"> 
       <div class="gr-promo-do-cliente"><?php the_field('tipo_de_promo');?></div> 
       <div class="gr-img-cliente"><a href="<?php the_permalink();?>" title="<?php the_title();?>"><img src="<?php echo get_field('foto_cliente_miniatura');?>" alt="" class="img-responsive center-block"></a></div> 
       <div class="gr-nome-cliente"><a href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?></a></div> 
       <div class="gr-tagline-cliente"><?php the_field('tagline_do_anunciante');?></div> 
       <div class="gr-bairro-do-cliente"><i class="cliente fa fa-map-marker"></i><?php the_field('bairro_do_cliente');?></div> 
      </div> 
     </div> 
    <?php endwhile; ?> 
    </div> <!-- Row --> 
</div> <!-- Container --> 

<?php else : // no results?> 
<article> 
    <h1>No Results Found.</h1> 
</article> 
<?php endif; ?> 
<?php get_footer(); ?> 

genesis(); 
+0

令人惊叹!就是这样!全心全意谢谢! – Artmaug

+0

很高兴听到您解决了您的问题 – Ajith