BASICS Canada
asked 8 years ago

hello,
Can you supply the code for me to change the ’15 Must Read’ so that what appears is our top 15 hitting posts of all time, instead of the current default latest 15 posts. Could you also supply code and instructions for us to select very specific posts.
Thanks,
Steve da Silva
BASICS Community News Service

1 Answers
Wilfred
answered 8 years ago

Hi Basics,
1. To show 15 hitting posts, please following my instruction here:
– Open functions.php file in /wp-content/themes/dw-focus/functions.php
– Replace the following code – from line 916 to line 921

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

with:

$post_array = array( 
'posts_per_page' => $max_number_posts,
'order' => 'DESC',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'orderby' => "meta_value_num",
'meta_key' => '_views',
);

– After that, login to Dashboard / Appearance / Customize / Navigation / Plus menu then select Display Latest new of the site
 
2. To show 15 specific posts, please following my instruction here:
– Creating a new category is specific posts (adding the slug of the category is specific-posts), add the category “specific posts” for the posts you want to show.
– Open functions.php file in /wp-content/themes/dw-focus/functions.php – Replace following code – from line 916 to line 921

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

with:

$post_array = array( 
'posts_per_page' => $max_number_posts,
'order' => 'DESC',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'orderby' => "meta_value_num",
'meta_key' => '_views',
'category_name' => 'specific-posts'
);

– Login to Dashboard / Appearance / Customize / Navigation / Plus menu then select Display Latest new of the site .
That’s all. Refresh the site to see the result.
Hope this helps!

Powered by DW Question & Answer Pro