modifying WP Query

I'm trying to modify the query bellow I tried to change the line $the_query = new WP_Query( array("post_type"=>"project_post") );

to  $the_query = new WP_Query( 'cat=4'  ); but it shows empty result on the page, my goal here is get all posts from specific category

original code:

                                                $the_query = new WP_Query( array("post_type"=>"project_post") );
                                                while ( $the_query->have_posts() ) : $the_query->the_post();
                                                $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'project_preview_big' );
                                                $image = $image[0];
                                                $categories = wp_get_post_terms($post->ID,"projects_category");
                                                $category = array();
                                                      foreach($categories as $categ){
                                                      $category = implode(",",$category);
                                                      $category = "";
                                                $cats = array();
                                                foreach($categories as $cat){
                                                $cats = implode(",",$cats);
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

the_query = new WP_Query( array("post_type"=>"project_post","cat"=>4) );
jakub99Author Commented:
It shows empty page e.g no posts are displayed also the filter button stops working.
It seams that you category isn't a built in category, but custom taxonomy.
Try to use "tax_query" e.g:

$args = array(
	'post_type' => 'project_post',//here your custom post type slug
	'posts_per_page'=> -1,
	'post_status' => 'publish',
	'orderby' => 'date',
	'order' => 'DESC',
	'tax_query' => array(
			'taxonomy' => 'your_custom_taxonomy_slug',//here your custom taxonomy slug
			'field' => 'slug',
			'terms' => 'your_term_slug',//here your custom taxonomy term slug
			//'include_children' => false,//optional (default is true)

$the_query = new WP_Query( $args );

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.