Search not showing all results

EDIT: So I've done some troubleshooting and it seems my theme isn't showing woocommerce search results. The 2017 theme does so I am trying to figure out what my theme is missing. I suspect something in the functions.php file. It's something I'm leaving out, not something I've included that's interfering, because I deleted all my code out of the functions file line by line and nothing changed.

I have some custom code I have used elsewhere without any trouble. I tried just copying it over to my new theme and for some reason, its not working. The search results show 1-10 of 54 but the first page only shows four results. The rest of the pages show nothing. I can't figure what I could be doing wrong.

In functions.php:

function wpse_106121_posts_count( $wp_query = null ) {
if ( ! $wp_query )
    global $wp_query;

    $posts = min( ( int ) $wp_query-get( 'posts_per_page' ), $wp_query-found_posts );
    $paged = max( ( int ) $wp_query-get( 'paged' ), 1 );
    $count = ( $paged - 1 ) * $posts;

    printf(
       '%d - %d of %d',
        $count + 1,
        $count + $wp_query-post_count,
        $wp_query-found_posts
    );
}

In search.php:

?php if ( have_posts() ) : ?
    p?php wpse_106121_posts_count() ?/p
    ?php while ( have_posts() ) : the_post(); 
    if ( '' !== get_post()-post_content ) : ? 

        h3a href="?php the_permalink(); ?"?php the_title(); ?/a/h3
            ?php the_excerpt(); ?
            pa href="?php the_permalink(); ?"Read More/a/p
            hr class="divider"
    ?php endif; endwhile; else : ?
    pNo posts found./p

?php endif; ?
div class="navigation"?php
global $wp_query;

$big = 99999;
$translated = __( '', 'themename' );

echo paginate_links( array(
    'base' = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' = '?paged=%#%',
    'current' = max( 1, get_query_var('paged') ),
    'total' = $wp_query-max_num_pages,
    'next_text' = __('NEXT '),
    'prev_text' = __(' PREV'),
) );
?/div

Topic functions php pagination Wordpress search

Category Web


Turns out I had an extra if statement in my search.php file that was filtering out content that didn't contain a proper excerpt.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.