Timeline for Main query disturb pre_get_post by category query
Current License: CC BY-SA 4.0
25 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 24, 2021 at 7:40 | comment | added | BlueSuiter | Is this worked for you? | |
Nov 23, 2021 at 12:00 | history | edited | BlueSuiter | CC BY-SA 4.0 |
added 38 characters in body
|
Nov 21, 2021 at 18:14 | comment | added | Joan Chaparro | Thanks BlueSuiter. EDIT in main entry are the two queries, for categories in the function.php and for the OBRES section. | |
Nov 21, 2021 at 10:39 | comment | added | BlueSuiter | oh you are storing year, than it seems you have doing something wrong with the query. please share the exact query you are using on the front page. | |
Nov 20, 2021 at 9:07 | comment | added | Joan Chaparro | only for the year? | |
Nov 19, 2021 at 19:01 | comment | added | BlueSuiter | i think it is better to store time stamp. what you say? | |
Nov 19, 2021 at 13:33 | comment | added | Joan Chaparro | it's a number for year and 20211119 Ymd for returned value in Concerts and 19/11/2021 d/m/Y for show. But after de button filter it works | |
Nov 19, 2021 at 12:24 | comment | added | BlueSuiter |
What is the date format you are using for the any field?
|
|
Nov 19, 2021 at 8:03 | comment | added | Joan Chaparro | The problem is in order of Obres and Concerts section. Concerts should be sorted by date, from newest to oldest. and Obres from newest to oldest year. | |
Nov 19, 2021 at 7:52 | comment | added | Joan Chaparro | stupendous-narwal.localsite.io Username: boundary Password: agreeable | |
Nov 18, 2021 at 5:38 | comment | added | BlueSuiter | Can I take a look at your website? | |
Nov 17, 2021 at 12:51 | comment | added | Joan Chaparro | Doesn't work. It's the same. When the page is loaded the post order it's not correct. When I've clicked the category buttons, it's fine. | |
Nov 17, 2021 at 6:30 | comment | added | BlueSuiter | Specify the category in arguments, then it will work fine. | |
Nov 16, 2021 at 13:59 | comment | added | Joan Chaparro |
If i put this query, the first order is ok, but the filter doesn't work well, It give me the number of post I expected but not the post that have category filtered. It could be for wp_reset_query()? . Where should I add wp_reset_query ()?
|
|
Nov 16, 2021 at 13:11 | comment | added | BlueSuiter |
$posts = get_posts(array( 'post_type' => 'obres', 'posts_per_page' => -1, 'meta_key' => 'any', 'orderby' => 'meta_value', 'order' => 'DESC' )); if( $posts ): while ( have_posts() ) : the_post(); this query i guess
|
|
Nov 16, 2021 at 13:00 | comment | added | Joan Chaparro | Sorry BlueSuiter I must not have explained well. This works well for me now. What doesn’t work is the initial sorting of posts. | |
Nov 16, 2021 at 12:53 | comment | added | BlueSuiter |
$query->set( 'orderby', 'meta_value_num' );
|
|
Nov 16, 2021 at 12:42 | comment | added | Joan Chaparro |
No, doesn't work. I put this on function.php and it works after applying filter but before order is not working!! $query->set( 'meta_key', 'data_del_concert'); $query->set( 'orderby', 'meta_value' );
|
|
Nov 16, 2021 at 12:26 | comment | added | BlueSuiter |
Change 'orderby' => 'meta_value', to 'orderby' => 'meta_value_num',
|
|
Nov 16, 2021 at 12:17 | comment | added | Joan Chaparro | yes is a year. I edited the initial post,... some suggest? Thanks | |
Nov 16, 2021 at 12:15 | comment | added | BlueSuiter | @JoanChaparro Is it a numeric value? | |
Nov 16, 2021 at 11:51 | comment | added | Joan Chaparro | BlueSuiter I changed & posts to $ posts_list and it worked !!! But now the sorting by the field 'ANY' does not work. | |
Nov 16, 2021 at 11:50 | vote | accept | Joan Chaparro | ||
Nov 16, 2021 at 11:56 | |||||
Nov 16, 2021 at 11:43 | comment | added | Joan Chaparro |
Thanks BlueSuiter. where I need to change the name variables and where should I add wp_reset_query ()? thanks
|
|
Nov 16, 2021 at 10:30 | history | answered | BlueSuiter | CC BY-SA 4.0 |