Orderby not correct with smaller numbers, please ‘year’ param
-
Dear Hector,
Thank you for this great plugin which is indeed a kind of heroic act.
Because I have some special needs (f.e. filtering footnotes, picture numbers, navigating elements and so on in the excerpt and singular/plural for no. of views) i made a custom version of a “most viewed” page for day, week, month and all.
For that I used your code to implement accordingly wp custom fields.
Here are excerpts of my code:
... $args = array( 'meta_key' => $feld, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => '1', 'posts_per_page' => $zahl ... while($last_loop->have_posts() && $counter <= $zahl ) : $last_loop->the_post(); $ID = $last_loop->post->ID; $thumb = getThumb($last_loop->post->ID); $url = get_permalink($last_loop->post->ID ); $text_title = get_the_title( $last_loop->post->ID ); $excerpt = clearTeaser(get_the_excerpt($last_loop->post->ID)); $views = wpp_get_views($last_loop->post->ID, $mode, true); ... endwhile;
$feld is f.e. ‘views_monthly’, $zahl is f.e. ’50’, $mode is f.e. ‘monthly’
Everything seemed to work fine. i also added a shortcode that works. But there are some small issues in detail:
- For “all” and “month” the sorting is correct. But for “day” and “week” either the sequence is wrong or the number for the views is determined wrong or both. There are even posts with 0 views in the listing (should not), followed by some with two or three views. Perhaps you have an idea what went wrong?https://182tage.net/blog/test-heute
- Additionally to orderby the custom field f.e. “month” there should be possible a second orderby date of last view, if numbers are equal. Is there a custom field for this already? XXX would be that custom field perhaps:
... $args = array( 'meta_key' => $feld, 'orderby' => [ 'meta_value_num' => 'DESC', 'XXX' => 'DESC'], 'ignore_sticky_posts' => '1', 'posts_per_page' => $zahl ...
- Last not least I would like to use the parameter “year” in addition to “day”, “week” and “month”. Would you add this option? I already gave a donation … some more could follow … thx a lot.
The page I need help with: [log in to see the link]
- The topic ‘Orderby not correct with smaller numbers, please ‘year’ param’ is closed to new replies.