$data = array post_type = post post_status = publish orderby = date order = ASC posts_per_page = 8 ;i want get posts by category id 5
To retrieve posts by category ID 5, you can modify the $data array as follows:
$data = array(
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => '8',
'cat' => 5,
);
By adding the 'cat' => 5 line, you specify that you want to retrieve posts from category ID 5.
原文地址: https://www.cveoy.top/t/topic/i36c 著作权归作者所有。请勿转载和采集!