2016-04-14 13 views
0

'da arama sonuçlarını gönderen bir WP eklentisi var. Bunu denediğinizde, ancak,Arama sonuçlarının sütunlarda görünmesini istiyorum, ancak sadece metin

<?php 
/** 
* Search & Filter Pro 
* 
* Sample Results Template 
* 
* @package Search_Filter 
* @author Ross Morsali 
* @link  http://www.designsandcode.com/ 
* @copyright 2015 Designs & Code 
* 
* Note: these templates are not full page templates, rather 
* just an encaspulation of the your results loop which should 
* be inserted in to other pages by using a shortcode - think 
* of it as a template part 
* 
* This template is an absolute base example showing you what 
* you can do, for more customisation see the WordPress docs 
* and using template tags - 
* 
* http://codex.wordpress.org/Template_Tags 
* 
*/ 


if ($query->have_posts()) 
{ 

    ?> 

    Found <?php echo $query->found_posts; ?> Results<br /> 
    Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> 


    <div class="pagination"> 

     <div class="nav-previous"><?php next_posts_link('Older posts', $query->max_num_pages); ?></div> 
     <div class="nav-next"><?php previous_posts_link('Newer posts'); ?></div> 
     <?php 
      /* example code for using the wp_pagenavi plugin */ 
      if (function_exists('wp_pagenavi')) 
      { 
       echo "<br />"; 
       wp_pagenavi(array('query' => $query)); 
      } 
     ?> 
    </div> 

    <?php 
    while ($query->have_posts()) 
    { 
     $query->the_post(); 

     ?> 

<div> 
      <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
      <?php 
       if (has_post_thumbnail()) { 
        echo '<p>'; 
        the_post_thumbnail("small"); 
        echo '</p>'; 
       } 
      ?> 
      <p><br /><?php the_excerpt(); ?><p> 
</div> 

     <?php 
    } 
    ?> 
    Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> 

    <div class="pagination"> 

     <div class="nav-previous"><?php next_posts_link('Older posts', $query->max_num_pages); ?></div> 
     <div class="nav-next"><?php previous_posts_link('Newer posts'); ?></div> 
     <?php 
      /* example code for using the wp_pagenavi plugin */ 
      if (function_exists('wp_pagenavi')) 
      { 
       echo "<br />"; 
       wp_pagenavi(array('query' => $query)); 
      } 
     ?> 
    </div> 
    <?php 
} 
else 
{ 
    echo "No Results Found"; 
} 

?> 

Şimdi SONUÇLARI (mesaj) 2 sütunlarda görünür istiyorum: İşte sonuç: php

<div class="container"> 
    <div class="row"> 
     <div class="col-md-2"> 
      <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
      <?php 
       if (has_post_thumbnail()) { 
        echo '<p>'; 
        the_post_thumbnail("small"); 
        echo '</p>'; 
       } 
      ?> 
      <p><br /><?php the_excerpt(); ?><p> 
</div> 
</div> 
</div> 

görebildiğim o metin (p) sütunlarda görünür, ancak sonuçlar değil.

Hedefe tam olarak nasıl ulaşırım?

+0

screenshot lütfen ?? –

+0

Bazı nedenlerden dolayı düzenlemelerimi kaydetmedim. Düzenlemiştim, orijinal cevabın ikinci kısmı yanlıştı. – user3078100

+0

Bu, elde ettiğim sonuçtur: http://prntscr.com/as53eg İleti sonuçlarının metinde değil, sütunlarda sıralanmasını istiyorum. – user3078100

cevap

1

Birkaç hata var. İlk col-md-2, bir 12 sütun düzeninden 2 sütun genişliğinde bir div yapar. Yani altıncı ve yarı değil. col-md-6 olmalıdır.

Ardından sıradaki sorun her posta için bir kapsayıcı, satır ve sütun ekliyor. Ama sadece 1 konteynerin ve 1 sıranın olması gerekir. Ve her yazı için sütun div yapmalısınız.

<!-- 1 container and row --> 
<div class="container"> 
<div class="row">  
<?php 
    while ($query->have_posts()){ 
    $query->the_post(); 
?> 
    <!-- a six column wide div for each post --> 
    <div class="col-md-6"> 
     <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
     <?php 
     if (has_post_thumbnail()) { 
      echo '<p>'; 
      the_post_thumbnail("small"); 
      echo '</p>'; 
     } 
     ?> 
     <p><br /><?php the_excerpt(); ?><p> 
    </div> 

<?php 
    } 
?> 
</div> 
</div> 
+0

Bunu yaptı! Yardımın için teşekkürler. – user3078100

İlgili konular