![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
-
AuthorPosts
-
June 25, 2018 at 8:58 am #977333
Hello, I’m new to editing functions.php
I added this code snipped to the .php file, but it’s just crashing the site when I upload it.
I have multiple blog pages that have different categories. I’d like them all to be sorted by earliest blog post first. Is there code that will affect this globally instead of each category?add_filter(‘avia_blog_post_query’, ‘avia_modify_post_grid_query_desc’);
function avia_modify_post_grid_query_desc( $query ) {
if( is_category( ‘japan’ ) ) {
$query[‘orderby’] = ‘title’;
$query[‘order’] = ‘DESC’;
return $query;
}
}-
This topic was modified 6 years, 2 months ago by
prospanicatc.
June 25, 2018 at 2:05 pm #977476Hey Andrew,
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Can you please check server log for error?
Best regards,
VictoriaJune 26, 2018 at 4:47 am #977775Hi Victoria
Is that the password to bluehost or the site itsefJune 26, 2018 at 5:23 pm #978031Hi prospanicatc,
Credentials did not work for me. Could you please update the credentials?
Best regards,
VictoriaJune 26, 2018 at 6:47 pm #978073Sorry about that
June 30, 2018 at 8:46 pm #979635Hi,
The login credentials still didn’t work for me. However please try to add this code to the child theme functions.php file to change the post order globally:
add_filter('avia_blog_post_query', 'avia_modify_post_grid_query_desc', 10); function avia_modify_post_grid_query_desc( $query ) { if( !empty($query) ) { $query['orderby'] = 'date'; $query['order'] = 'ASC'; } return $query; }
You can replace ASC with DESC to revert the order.
Best regards,
DudeJuly 4, 2018 at 9:38 am #981022Ok I know this username and password work, I just tested it out myself.
How do I do it so the main blog page shows the latest one at the top, but other pages such as http://loosyourselfabroad.com/blog/japan-2017/ are sorted descending?July 5, 2018 at 9:42 pm #981747Hi,
Now I could log in but the account does not have admin rights (so we can’t edit pages, access the theme editor, etc.)
If you just want to change the sort order on pages which are not used as the home/front page or your main blog (http://loosyourselfabroad.com/blog/) you can try this code:
add_filter('avia_blog_post_query', 'avia_modify_post_grid_query_desc', 10); function avia_modify_post_grid_query_desc( $query ) { if(!empty($query) && !is_home() && !is_front_page() && !is_page('2')) { $query['orderby'] = 'date'; $query['order'] = 'DESC'; } return $query; }
Best regards,
DudeJuly 6, 2018 at 5:00 am #981814Shoot sorry about that. Fixed the permissions. Where do I put this query?
July 7, 2018 at 8:27 am #982326July 7, 2018 at 1:17 pm #982438That worked beautifully thank you
July 7, 2018 at 8:25 pm #982560Hi prospanicatc,
Glad we could help :)
If you need further assistance please let us know.
Best regards,
Victoria -
This topic was modified 6 years, 2 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.