Search within a category in worpdress

I’m trying to search within a single category on wordpress using the code below

`

    $args = new WP_Query( 'cat=199' );
    if( $args->have_posts() ){

    while ( $args->have_posts() ){ $args->the_post();
        get_template_part('content', 'what-we-eat');

    } ?>

    <?php   

    }
    else{
        _e( 'Sorry, no posts matched your criteria.' );
    }

`

however, the results shows all of the posts within that category even though the search term updates with the search term used.

Any ideas where i’m going wrong?

Read more here: Search within a category in worpdress

Leave a Reply

Your email address will not be published. Required fields are marked *