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


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: