Zhenyu QI
asked 7 years ago

refer to: http://cmspioneer.com/designwall/question/how-to-fetch-15-must-read-articles-from-a-category/

I have the same question, I only need to fetch “15 Must Read Articles” from a category, I have created a category called “mustread”, can you tell me how to changing functions.php to achieve the object?

Thank you!

5 Answers
DominicStaff
answered 7 years ago

To solve this issue, please open the functions.php file /go to line 799 -> 804.
Replace the following codes:

 $post_array = array(
'posts_per_page' => $max_number_posts,
'order' => 'DESC',
'post_status' => 'publish',
'ignore_sticky_posts' => 1
);

With new codes:


$post_array = array(
'posts_per_page' => $max_number_posts,
'order' => 'DESC',
'post_status' => 'publish',
'ignore_sticky_posts' => 1
);
$post_array['category__in'] = array( /*categories ids ex: 1, 2, 3*/);

See the Screenshot below:

Please change your categories ID here: /*categories ids ex: 1, 2, 3*/
If you want to know Id of the categories, you can hover on the categories.
See the screenshot:

Zhenyu QI
answered 7 years ago

thank you for your reply! if the category id of “mustread” is 23, then the right code is:

$post_array = array(
'posts_per_page' => $max_number_posts,
'order' => 'DESC',
'post_status' => 'publish',
'ignore_sticky_posts' => 1
);
$post_array['category__in'] = array(category id: 23);

is that right?

DominicStaff
answered 7 years ago

Please add the following code:

 $post_array['category__in'] = array(23);
Zhenyu QI
replied 7 years ago

thank you very much!

shae101s
replied 7 years ago

Actually, question..how do we remove the date from also showing in that area? I don’t want a date stamp in the dropdown of the 15 Must Read articles, how do I remove that?

shae101s
answered 7 years ago

Thanks for sharing this, I was also wondering how to achieve this very thing!

DominicStaff
answered 7 years ago

@Shae101s !
To resolve your issue, you can add the following code to the “Header Script”

<style>
.desktop .top-news .entry-meta {
    display:none;
}
</style
Powered by DW Question & Answer Pro