• Hello,
    I want to get custom posts by category ID,
    I tried this way
    get_posts('post_type=portfolio&category=' . $category->cat_ID)
    But Unfortunately it’s giving me back an empty array.

    Any help, please?

Viewing 1 replies (of 1 total)
  • Thread Starter Khal3d

    (@khal3d)

    I found the solution to get custom posts By category “term” Not ID

    $posts = new WP_Query(array('taxonomy' => 'portfolio-categories', 'term' => $category->slug));
    		while ( $posts->have_posts() )
    		{
    			$posts->the_post();
    			// Dot somethings
    		}
    		wp_reset_query();
Viewing 1 replies (of 1 total)
  • The topic ‘How can I get custom posts by category?’ is closed to new replies.