Answers for "wp_query post by category taxonomy"

PHP
3

wp_query post by category id

$args=array(
    'posts_per_page' => 50, 
    'post_type' => 'my_custom_type'
    'cat' => $cat_id,
);
$wp_query = new WP_Query( $args );
Posted by: Guest on June-20-2021
0

wp_query post by category taxonomy

// If the taxonomy is the default category then:
$args = array( 
  'post_type'   => 'post',
  'category_name' => $category_name,
  'no_found_rows'          => true,
  'update_post_term_cache' => false,
  'update_post_meta_cache' => false,
);
$posts = new WP_Query( $args );
Posted by: Guest on February-13-2022

Browse Popular Code Answers by Language