검색 결과에 문제가 있습니다. 이미 검색 테마를 만듭니다. "데이터베이스"라는 단어를 검색하면 결과가 모두 반환되어 제대로 작동하지만 게시물과 페이지가 아닌 특수 사용자 정의 게시물 유형을 검색하려고합니다.특별 맞춤 게시물 유형에서 검색
여기에 어떤 생각이 충당 될 것이다
<?php
get_header(); ?>
<div class="title-pack col-md-12 col-sm-12 col-xs-12">
<span class="line visible-sm-block"></span>
<span class="visible-sm-block tittle-style">نتایج جستجوی شما</span>
</div>
<div id="search-results" class="wrapper" role="search">
<!-- COUNT RESULTS -->
<div class="results">
<?php
/* Search Count */
$allsearch = &new WP_Query("s=$s&showposts=-1");
$key = wp_specialchars($s, 1);
$count = $allsearch->post_count;
_e('');
_e('"<span class="search-terms">');
echo $key;
_e('</span>"');
echo $count . ' مورد یافت شد';
wp_reset_query(); ?>
</div>
<!--/COUNT RESULTS -->
<?php if ($allsearch->have_posts()) : ?>
<?php while ($allsearch->have_posts()) : $allsearch->the_post(); ?>
<!-- LIST RESULTS -->
<section>
<h3>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to
<?php the_title_attribute(); ?>"><?php the_title(); ?></a> -
<span class="search-time"><?php the_time('F, j, Y') ?></span>
</li>
</h3>
</section>
<!--/LIST RESULTS -->
<?php endwhile; else: ?>
<!-- 404 SEARCH -->
<div class="404-search">
<?php _e("Oops... We couldn't find what you were searching for. Please try again"); ?>
</div>
<!--/404 SEARCH -->
<?php endif; ?>
</div>
<div style="clear:both;"></div>
<?php get_footer(); ?>
<div style="clear:both;"></div>
<?php get_footer(); ?>
내 코드입니다.
나는이 라인이 무엇인지를 요청할 수'S = $ S & showposts = -1'을했다 ??? 나는 항상 wp_query를 쓰지 만 그 라인과 섞는다. – mkafiyan
'$ s'는 검색 키워드이다. showposts = -1은 모든 결과를 반환한다는 것을 의미하고, 페이지 매김 목적을 위해, 당신은 숫자를 제한 할 수있다. 'postposts = 6'은 한 번에 최대 6 개의 게시물을 반환합니다. 'posts_per_page'=> -1'은 같은 것입니다 –
감사합니다. – mkafiyan