it’s possible to set OrderBy to a post_meta_date?
I have an acf-datefield which i set in the template as post_meta_date key=”datefield”. That’s fine.
But i can’t select this as groupby, only als meta value key – but in this case, i can’t select YearMonth or anything similar.
]]>Is their a possibility to add or change this?
By-the-way, in the sort-function for a post it is not possible to sort after the excerpt. It were very nice, if the plugin can sort for it.
]]>This article EVENT AND LOCATION GROUPING AND ORDERINGsaid, that groupby and orderby can be use with any field from wp_em_events and wp_em_locations tables. So I decided to change the event_slug field of the any event. It is now category-term_id plus the event_name. This can be done by a plugin later that fires on save new or edit events.
Example data:
Event1 – Name: “Konzert”, Category-Name: “Bühne”, Category-Term-ID(Bühne): “219”, new event_slug: “219-konzert”, start_date: 21.02.2019 19:30
Event2 – Name: “Theater”, Category-Name: “Kinder”, Category-Term-ID(Kinder): “220”, new event_slug: “220-theater”, start_date: 21.02.2019 20:30
Event3 – Name: “Party”, Category-Name: “Bühne”, Category-Term-ID(Bühne): “219”, new event_slug: “219-party”, start_date: 21.02.2019 23:30
On the event page I use this:
[events_list_grouped mode=”daily” orderby=”event_slug”]#_EVENTNAME<br/>[/events_list_grouped]
So I hope, I get this output order: Event1, Event3, Event2 – first the events from the category “Bühne”, then category “Kinder”.
But I get this: Event1, Event2, Event3. It is still ordered by start_date.
In another test I edit the fields group_id from table wp_em_events and save the category-term-id in there. No Buddypress needed, so the field is empty and useless for this page. But this failed too.
Is it really true that orderby can be use with any field from wp_em_events? How can I handle this?
]]>I have a category called revue-series that contains anime,docs,designing-the-movies, and parent-and-baby. I thought if I listed the parent category in the category_name argument it would save me the trouble to add new categories.
So the following shortcode worked as expected:
[wpt_productions start=”now” category_name=”revue-series”]{{thumbnail|permalink}}{{title|permalink}}{{summary}}[/wpt_productions]
But when I added group by… all the categories I have, even others not under revue-series showed up as well in the list:
[wpt_productions start=”now” category_name=”revue-series” groupby=”category”]{{thumbnail|permalink}}{{title|permalink}}{{summary}}[/wpt_productions]
I try using the following shortcode to specify just the children categories:
[wpt_productions start=”now” category_name=”anime,docs,designing-the-movies,parent-and-baby”]{{thumbnail|permalink}}{{title|permalink}}{{summary}}[/wpt_productions]
It returns the same result as the first shorcode with just the parent category. But when I added the groupby argument it returns also the parent category for the listed categories so after all 4 catetories Revue series is shown with all events listed again:
[wpt_productions start=”now” category_name=”anime,docs,designing-the-movies,parent-and-baby” groupby=”category”]{{thumbnail|permalink}}{{title|permalink}}{{summary}}[/wpt_productions]
Is this working as suppose to? is like the groupby is working in the whole set and not the filtered results by category.
Thanks in advance!
]]>I’m trying to regroup posts containing different meta values & to display only last posts written for each meta value.
So I wrote this piece of code :
add_filter('posts_groupby', 'query_group_by_filter');
function query_group_by_filter($groupby){
global $wpdb;
return $wpdb->postmeta . '.meta_value';
}
// WP_Query arguments
$args = array (
'post_type' => 'post',
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'date',
'meta_query' => array(
array(
'key' => 'article_information_artiste',
),
),
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post(); ?>
// Do something
<?php }
} else {
echo "No content!";
}
remove_filter('posts_groupby', 'query_group_by_filter');
// Restore original Post Data
wp_reset_postdata();
It regroups posts with specific meta values but it displays only the first post, not the last one.
I try to add to the wp_query order & orderby argument but nothing happens.
Do you know how to display only last post written for each meta value ?
Here a preview
Thanks for your help.
]]>I’m using the groupby=”day” format, but it’s only showing ‘zaterdag 11 juni’ for example, and I would like it to show ‘zaterdag 11 juni 2016’.
Do you know how to resolve this?
Thanks for the awesome plugin, it has already saved me loads of time!
Roxanne
https://www.ads-software.com/plugins/theatre/
]]>I hope somebody could help and we ll finally come to an answer.
Many thanks in advance!
Tche
]]>Have finally found out the reason, if any other plug in, is using a groupby clause in there sql, your function will break it.
Because you dont check !!!!!!!!!!!!!!!!
So you get a sql query with
GROUP BY wp_posts.ID guid
which surprise, surprise DOES NOT WORK !
In this case, was clashing with the “Enhanced Media Library” plugin
If you are going to add / change base functionality, it would help if you remember that you are not the only plugin in the world.
Have now changed this to
public function group_attachments($groupby) {
if ($groupby != ”) {
$groupby .= ” , guid”;
} else {
$groupby .= ” guid”;
}
return $groupby;
}
Will see if this works
https://www.ads-software.com/plugins/maxgalleria/
]]>I program the use of W4 to display various lists of posts, which are a part of special posts for the users which are reviewers. The purpose of these posts, which can be accessed only be reviewers, is to help the review of posts during publish process and before publish status ..
Then depending of the selection of posts done, it is useful to be able to group (group by) the posts using status
Best regards
Trebly
https://www.ads-software.com/plugins/w4-post-list/
]]>what I’m trying to do is grouping posts by its ID. I don’t know why, but I get duplicates.
So what I tried was to do the following:
<?php
$args = array(
'post_status' => 'publish',
'author' => 6,
'groupby' => 'wp_posts.ID',
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1,
);
query_posts($args);
get_template_part('template', 'loop'); ?>
But that doesn’t do anything. Anyone knows a solution?
Thanks
]]>