2014-03-28 3 views
0

저는 Wordpress를 처음 접했고 reverie-master로 테마를 만들었지 만 유일한 문제는 검색 페이지입니다. 다른 모든 페이지, 카테고리, 아카이브 등이 작동합니다.Wordpress 검색 페이지 홈페이지에로드

나는 내 header.php에서 검색을 위해 이것을 사용

<form method="post" action="<?php echo home_url('/'); ?>" class="search-form" role="search"> 
    <div class="small-9 columns no-pad"> 
     <input type="text" class="search-input" name="s" placeholder="Search" value="" /> 
    </div> 
    <div class="small-3 columns no-pad"> 
     <input class="btn-submit postfix search-input" type="submit" value=""/> 
    </div> 

이이 홈페이지의 검색 결과를 보여줍니다. 검색 창에 "ok"라고 입력하면 www.homepage.com/?s=ok에있을 때 www.homepage.com으로 이동합니다. 홈 페이지에있는 문제는 페이지 블로그가 www.homepage.com/page/2/에서 홈페이지 블로그 피드의 2 페이지로 이동하게됩니다. www.homepage.com/page/ 2 /? s = test

브라우저의 url을 수동으로 입력 할 때 : www.homepage.com/page/2/?s=test 페이지 매김이 작동합니다. 내 문제는 페이지 매김하고 여기에

내 search.php 코드 (나는 문제가 가정) 홈페이지에서 게시물을 표시 왜 궁금 : 이것은와 사이에 루프입니다

Starts with <?php get_header(); ?> and ends with <?php get_footer(); ?> 

페이지 매김 :

<h2><?php _e('Search Results for', 'reverie'); ?> "<?php echo get_search_query(); ?>"</h2> 

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

       <?php /* Start the Loop */ ?> 
       <?php while (have_posts()) : the_post(); ?> 
        <div class="row pad-row"> 
         <div class="large-11 columns bor-bottom"> 
          <a class="fade" href="<?php the_permalink(); ?>"><p class="feed-title"><?php the_title(); ?></p></a> 
          <p class="feed-info">By <span class="feed-author"><?php the_author(); ?> </span> &#149; <?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?> &#149; 
          <?php 
          foreach((g_the_category()) as $category) { 
           if ($category->cat_name != 'featured') { 
            echo '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . '>' . $category->name.'</a> '; 
           } 
          } 
          ?> 
          &#149; <span class="feed-cmt"><?php comments_number('0 Comments', '1 Comments', '% Comments'); ?>. </span></p> 
          <?php the_excerpt(); ?> 
         </div> 
        </div> 
       <?php endwhile; ?> 

       <?php else : ?> 
        <?php get_template_part('content', 'none'); ?>  
       <?php endif; // end have_posts() check ?> 



      <!-- Start Pagination --> 

      <div class="row pad-row"> 
       <div class="large-11 columns pagination-centered large-centered panel-page"> 
        <?php /* Display navigation to next/previous pages when applicable */ ?> 
        <?php if (function_exists('reverie_pagination')) { reverie_pagination(); } else if (is_paged()) { ?> 
         <nav id="post-nav"> 
          <div class="post-previous"><?php next_posts_link(__('&larr; Older posts', 'reverie')); ?></div> 
          <div class="post-next"><?php previous_posts_link(__('Newer posts &rarr;', 'reverie')); ?></div> 
         </nav> 
        <?php } ?> 
       </div> 
      </div> 

답변

1

검색 양식을 직접 입력하지 마십시오. WP에는 get_search_form()이라는 검색 양식을 가져 오는 기능이 있습니다. 이 함수는 기본 검색 양식을 인쇄하지만 여전히 사용자 정의 할 수 있습니다. 맞춤 설정하려면 get_search_form이라는 필터를 사용할 수 있습니다.

function custom_search_form($form) { 
    $form = '<form method="get" action="' . home_url('/') . '" class="search-form" role="search"> 
    <div class="small-9 columns no-pad"> 
     <input type="text" class="search-input" name="s" id="s" placeholder="Search" value="' . get_search_query() . '" /> 
    </div> 
    <div class="small-3 columns no-pad"> 
     <input class="btn-submit postfix search-input" id="searchsubmit" type="submit" value="'. esc_attr__('Search') .'"/> 
    </div> 
    </form>'; 

    return $form; 
} 

add_filter('get_search_form', 'custom_search_form'); 

그리고 functions.php에 근무

+0

덕분에이를 넣어 – moni