2012-07-12 2 views
0

결과를 표시하기 위해 검색 양식과 search.php 파일을 만들었습니다. 유일한 것은 콘텐츠와 제목 대신 태그를 포함하여 필터링하려고합니다. 이 프로세스에 대한 wordpress 기능이 있습니까?카테고리 및 태그별로 WordPress 결과를 필터링하는 방법은 무엇입니까?

검색 폼 코드 :

<?php if(is_category(array('general-support','activities','discount-cards','equipment','financial','holidays','medical','respite')) || is_single()){?> 

<div style="width:auto; margin:0px 40px 0px 20px;"> 

    <form role="search" action="<?php bloginfo('siteurl');?>" style="margin:0px; padding:0px;"> 

     <div> 
      <h2>Search for</h2> 
      <div><input type="text" name="s" id="s" style="width:100%; padding:5px; border:1px solid #ccc; box-shadow:inset 1px 1px 1px #f0f0f0;" /></div> 
      <div><input type="hidden" value="14,16,21,18,20,15,22,19,17" name="cat" id="scat" /></div> 
     </div> 

    </form> 

</div> 

<?php } ?> 

Search.php

<?php query_posts($query_string . '&showposts=10'); ?> 

<?php if (have_posts()) : ?> 

    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> 

<?php while (have_posts()) : the_post(); ?> 


<div <?php post_class() ?> id="post-<?php the_ID(); ?>"> 
    <div class="entry"> 

     <!--start.entry-wrapper--> 
     <div class="entry-wrapper"> 

      <!--start.post-thumbnail--> 

      <?php if(has_post_thumbnail()){?> 

      <div class="post-thumbnail-wrapper"> 
       <a href="<?php the_permalink();?>"> 
        <?php the_post_thumbnail('category-thumb'); ?> 
       </a> 
      </div> 

      <?php } ?> 

      <!--end.post-thumbnail--> 

      <!--start.post-entry---> 
      <div class="post-enry-wrapper"> 
       <h2><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('Permalink to %s', 'udesign'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></h2> 
       <div class="postmetadata"> 
        <?php the_content();?>    
       </div> 
      </div> 

      <!--end.post-entry--> 
      <div class="clear"></div> 
     </div> 
     <!--end.entry-wrapper--> 

    </div> 

    <?php if(!is_category() && !is_single()){?> 

    <div><?php if(function_exists('kc_add_social_share')) kc_add_social_share(); ?></div> 

    <?php }?> 

</div> 
<div class="addGap"></div> 
<?php endwhile; ?> 

<div class="clear"></div> 

<?php  // Pagination 
if(function_exists('wp_pagenavi')) : 
    wp_pagenavi(); 
else : ?> 

    <div class="navigation"> 
    <div class="alignleft"><?php previous_posts_link() ?></div> 
    <div class="alignright"><?php next_posts_link() ?></div> 
</div> 

<?php  endif; ?> 

은 알려 주시기 바랍니다, 나는 어떤 플러그인을 사용하고 싶지 않아요.

답변

0

나는 당신의 질문을 이해 가정하면,이 도움이 될 것입니다

http://codex.wordpress.org/Function_Reference/wp_get_post_terms

을 여러 분류법을 (보다 그냥 태그)이 있고, 하나의 알파 정렬 된 배열로 병합 알려하고자하는 경우. 어딘가에 병합/정렬을 수행하는 함수가 있습니다.

관련 문제