Here is my query:

$args = array(
    'post_type' => 'jobs',
    'cat' => $category_id,
    'tag' => $searchval,
    'paged' => $paged

But this not working.

  • Impossible to answer without seeing the source of your variables and your complete debug information.
    – fuxia
    Commented May 16, 2017 at 12:39

1 Answer 1


It's highly recommended NOT to use query_posts() function as this can affect a LOT of different things.

While this question is especially difficult to answer when you don't specify how it's not working and the source of your variables, the better way to formulate this query would be by using the filter entitled 'pre_get_posts'.


add_filter( 'pre_get_posts', 'wpse_267038_jobs_posts' );
function wpse_267038_jobs_posts( $query ) {
    if ($query->is_main_query() ) {
        $query->set( 'post_type', 'jobs' );
        $query->set( 'cat', $category_id );
        $query->set( 'tag', $searchval );
        $query->set( 'paged', $paged );

While we can't check to be sure that achieves the proper results because of your lack of details, this is the way to go about it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.