ventatto
Forum Replies Created
-
Surprisingly, without doing anything, ‘Age’ column came back in the meantime…
First player list:



Second player list:



Do you have an idea of a potential solution ?
Thanks
Just did it (troubleshooting with only SportsPress enabled and cleared cache) with three themes but still the same issue…
Hi,
I have just given a try with
RookieandTwentyTwentybut still the same problem.Indeed in your examples it works as it should be but in several of my player lists as well. The issue only occurs for few player lists, like the one in the provided link.
It is the case, I have the same result using shortcode or not, which is problematic. What I said initially is that two different player lists with the same column properties do not display the same outcome format (the one I refer to with the screenshots seems to not take the columns selection into account)…
Hi,
Here is the shortcode :
[player_list 16599](but the same problem occurs when displaying directly the player list without shortcode).Great it works and I could do my first message 🙂
Thanks a lot !
Forum: Developing with WordPress
In reply to: parse_query() orderby date ignoring yearI tried again several times differently but still the same issue…
I eventually looked for another way to address the problem and found a reordering after doing
get_posts($posts). Here it is :function cmp_birthday($a, $b) { $month1 = date('m', strtotime($a->post_date)); $month2 = date('m', strtotime($b->post_date)); $cmp = strcasecmp($month1, $month2); if ($cmp == 0) { $day1 = date('d', strtotime($a->post_date)); $day2 = date('d', strtotime($b->post_date)); return strcasecmp($day1, $day2); } else return $cmp; } usort($posts, "cmp_birthday");I really want to thank you for the time you spent trying to find a solution for me.
Best regards.
Forum: Developing with WordPress
In reply to: parse_query() orderby date ignoring yearJust did it (at the end of
functions.phponly because I don’t find a suitable main plugin file). Still the same issue with the function which is well entered and returned but after the players having been displayed in the wrong default order…Forum: Developing with WordPress
In reply to: parse_query() orderby date ignoring yearOk I understand, that was absolutely not how I was seeing it. Thanks for it.
Therefore I tried to add my filter before. I did a
debug_print_backtrace()to see the callers until the query creation and tried to add my filter but unfortunately, no one worked (I did the tries in the calling function of two of the plugin files as well as inclass-wp-widget.phpandwidgets.php)Forum: Developing with WordPress
In reply to: parse_query() orderby date ignoring yearThe problem is that the associated query is created just before the call to
add_filter()in my code. So if I move myadd_filter()in the caller for example, there’s no query to pass imo…I tried another way with a closure (to ensure that the query was the one I wanted) but it was not more successful…
Forum: Developing with WordPress
In reply to: parse_query() orderby date ignoring yearI verified and it correctly enters in the condition. When I
echothe value of$orderbybefore thereturninbirthday_sort(), it contains what is expected. But these birthdays are displayed in a widget and while debugging, I noticed that it was entering the function (and so executingadd_filter()) in the widget following the “Birthdays” one (myechowere displayed in the following widget)… I don’t know if it can help getting the solutionForum: Developing with WordPress
In reply to: parse_query() orderby date ignoring yearAlright I removed
pre_get_posts. However, I don’t only want the month number as criteria since I want them to be ordered by anniversary. If I have someone who’s anniversary is on 12/03 and another one on 14/03, I want to be sure that the 14/03 appears after the 12/03, which would be random by only looking at the month number.However, I tried your solution as well as an adaptation of it with
DAYinstead ofMONTHbut the order remains unchanged whenget_posts( $args )is called afterwards.add_filter( 'posts_orderby', 'birthday_sort', 10, 2 ); function birthday_sort( $orderby, $args ) { if ( ! is_admin() && 'post_date' === $args->get( 'orderby' ) ) { global $wpdb; $order = ( 'ASC' === strtoupper( $args->get( 'order' ) ) ) ? 'ASC': 'DESC'; $orderby = 'DAY( post_date ) ASC'; } return $orderby; }