ranking by comments doesn’t work on post page
-
We used exactly the same code on the home page, the category pages and the post pages. Only the post pages have the problem that ranking by comments doesn’t work (ranking by views works however).
Can you help?
-
Hey there!
Can’t help much without knowing what you did over there so let’s see some code first. More details on what’s happening would help too, “it doesn’t work” doesn’t say a lot. What exactly isn’t working? What’s happening?
Hey Hector!
This is the code we use. It works well on other pages including the home page. Only on the post pages, the comments list will show as the same as the daily list.
[Large code excerpt removed by moderator per forum rules. Please use Pastebin or a Gist for all large code excerpts, they work better anyway.]
It won’t display the top comments posts (best guess is that it is unable to fetch the relevant data or perhaps have trouble displaying it).
-
This reply was modified 7 years, 8 months ago by
James Huff.
Please wrap your code using the code button (or use pastebin.com instead.)
apologies Hector – code is below:
<div id="popular-news"> <ul class="nav nav-pills"> <li class="active"> <a data-toggle="tab" href="#weekly"> <h3 class="popular-news-title">本周排行</h3> </a> </li> <li> <a data-toggle="tab" href="#daily"> <h3 class="popular-news-title">每日排行</h3> </a> </li> <li> <a data-toggle="tab" href="#comments"> <h3 class="popular-news-title">评论排行</h3> </a> </li> </ul> <div class="tab-content"> <div id="weekly" class="tab-pane in active"> <?php $args = array( 'header_start' => '<h3 id="popular-news-title">', 'header_end' => '</h3>', 'limit' => 10, 'range' => 'weekly', 'freshness' => 1, 'order_by' => 'views', 'post_type' => 'post', 'wpp_start' => '<ol id="popular-news-list">', 'wpp_end' => '</ol>', 'post_html' => '<li><a target="_blank" title="{text_title}" href="{url}">{text_title}</a><span style="visibility: hidden;" class="popular-news-view-count">{views}</span></li>' ); wpp_get_mostpopular($args); ?> </div> <div id="daily" class="tab-pane"> <?php $args = array( 'header_start' => '<h3 id="popular-news-title">', 'header_end' => '</h3>', 'limit' => 10, 'range' => 'daily', 'freshness' => 1, 'order_by' => 'views', 'post_type' => 'post', 'wpp_start' => '<ol id="popular-news-list">', 'wpp_end' => '</ol>', 'post_html' => '<li><a target="_blank" title="{text_title}" href="{url}">{text_title}</a><span style="visibility: hidden;" class="popular-news-view-count">{views}</span></li>' ); wpp_get_mostpopular($args); ?> </div> <div id="comments" class="tab-pane"> <?php $args = array( 'header_start' => '<h3 id="popular-news-title">', 'header_end' => '</h3>', 'limit' => 10, 'range' => 'weekly', 'freshness' => 1, 'order_by' => 'comments', 'post_type' => 'post', 'wpp_start' => '<ol id="popular-news-list">', 'wpp_end' => '</ol>', 'post_html' => '<li><a target="_blank" title="{text_title}" href="{url}">{text_title}</a><span>{comments}</span></li>' ); wpp_get_mostpopular($args); ?> </div> </div> </div>
Hey there!
Thanks for sharing the code. At first glance there doesn’t seem to be anything wrong with it.
More details on what’s happening would help too, “it doesn’t work” doesn’t say a lot. What exactly isn’t working? What’s happening?
Could you please describe in detail what’s going on so I can try to replicate it over here?
Hi Hector!
This is what we expect (the correct behaviour on the home page): the middle tab indicates ranking by views and the right tab is ranking by comment counts.
https://s3-ap-southeast-2.amazonaws.com/s3-1688-wp-media/temp/1.png
=> https://s3-ap-southeast-2.amazonaws.com/s3-1688-wp-media/temp/2.png
This is what we got on the post page: the middle tab and the right tab are the same.
https://s3-ap-southeast-2.amazonaws.com/s3-1688-wp-media/temp/3.png
=> https://s3-ap-southeast-2.amazonaws.com/s3-1688-wp-media/temp/4.png
Using the exact same code. (WordPress v4.75 – WordPress Popular Posts 3.3.4)
Let me know if anything else I need to clarify.
Cheers!
Hi @danielklam!
Apologies for the delay. Somehow I missed your reply, just saw it now.
I tried your code with the Twenty Seventeen theme. Here’s what I got:
Home page:
single.php:
page.php:
As you can see the wpp_get_mostpopular() template tag behaved as expected: every tab displayed the right listing regardless of which page I was on.
Try switching to another theme for a moment and see if you can replicate the issue or not.
Marking as resolved due to inactivity.
-
This reply was modified 7 years, 8 months ago by
- The topic ‘ranking by comments doesn’t work on post page’ is closed to new replies.