hi all
i am new in WordPress , i have problem in search engine
i use pagination and custom post type in my site .
when i try search its give no result .
i don't know how solve this problem
this my code :
function.php
// category pagination
function wpa85791_category_posts_per_page( $query ) {
if ( $query->is_category() && $query->is_main_query() )
$query->set( 'posts_per_page', 8 );
}
add_action( 'pre_get_posts', 'wpa85791_category_posts_per_page' );
// pagination
function wpbeginner_numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div class="navigation">
' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '
%s
' . "\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '<li%s>%s' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '
…
';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s>%s' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '
…
' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s>%s' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '
%s
' . "\n", get_next_posts_link() );
echo '
</div>' . "\n";
}
and this code to post 8 subject .
index.php
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_type' => 'post', 'posts_per_page' => 8, 'paged' => $paged );
$wp_query = new WP_Query($args);
?>
and this in code
searchform.php
<h2>Search</h2>
<div class="content">
<form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div>
<label for="s">Search for:</label>
<input type="text" class="field" name="s" id="s" />
<input type="hidden" id="searchsubmit" value="Search" />
</div>
</form>
please anyone help .