Tagged: order by, orderby, post slider, postslider
-
AuthorPosts
-
March 19, 2014 at 5:30 pm #240185
First of all, i love the Enfold theme, good job!
I have Blog posts with a like-dislike counter, the like dislike counts are stored within the database.
I have added the number of likes for each post to the postslider.php, and i echo them just above the title (into a div span)
This way visitors can see the likes in the postslider.Now i would like to order the blog posts according to their likes (most likes first, least likes last).
Is there a way to sort the posts according to the number of likes? The custom field does not have meta-data to it.
March 20, 2014 at 3:12 am #240468Hey DennisDriessen!
No not that I can think of or already know of. It would most likely need to be a new custom function to modify the query to sort by that number.
Best regards,
DevinMarch 20, 2014 at 9:41 am #240581Hi Devin,
Thank you for you fast reply!
There is a query filter in the postslider.php script; it seems to take ‘date’ and ‘rand’ but it won’t work with ‘title’ or any other standard “orderby” parameter. Any idea why this query won’t take anything else?the query:
$query = array( ‘orderby’ => ‘rand’,
‘order’ => ‘ASC’,
‘paged’ => $page,
‘post_type’ => $params[‘post_type’],
‘posts_per_page’ => $params[‘items’],
‘offset’ => $params[‘offset’],
‘post__not_in’ => (!empty($no_duplicates)) ? $avia_config[‘posts_on_current_page’] : array(),
‘tax_query’ => array( array( ‘taxonomy’ => $params[‘taxonomy’],
‘field’ => ‘id’,
‘terms’ => $terms,
‘operator’ => ‘IN’)));Best regards,
DennisMarch 21, 2014 at 12:01 am #240927You can add a filter to change the query like this:
http://www.dailyblogging.org/wordpress/increase-wordpress-memory-limit/February 21, 2020 at 1:27 pm #1186702Hi,
I’m beginner, I need order my post slider and I change this function from:
add_filter(‘avia_post_slide_query’, ‘enfold_customization_query_custom’);
function enfold_customization_query_custom( $query ) {
$query[‘orderby’] = ‘rand’;
return $query;
}To:
add_filter(‘avia_post_slide_query’, ‘enfold_customization_query_custom’);
function enfold_customization_query_custom( $query ) {
$query[‘orderby’] = ‘desc’;
return $query;
}But this doesn’t work, could you help me?
Thank you and best Regards
February 24, 2020 at 4:38 pm #1187392Hi Partecipant,
The code you posted seems to be correct but the quotes might be the ones causing the issue.
Please retype the quotes'
Let us know if it helps.
Best regards,
Nikko -
AuthorPosts
- You must be logged in to reply to this topic.