Community Forums › Forums › Archived Forums › Design Tips and Tricks › Front page displays latest updated post
Tagged: genesis_grid_loop_args
- This topic has 13 replies, 2 voices, and was last updated 8 years, 2 months ago by
Brad Dalton.
-
AuthorPosts
-
December 3, 2016 at 2:38 pm #196954
jaychan
ParticipantHello,
I use Genesis Simple theme and would like to modify the default reading settings. I would like to display "latest updated posts" instead of "latest posts", everywhere.
Would there have a way to do it, please?
Thank you.
December 4, 2016 at 5:29 am #196964Brad Dalton
ParticipantYou can use the orderby parameter for modified
'orderby' => 'modified'
You can use this with WP_Query or genesis_custom_loop.
See the page_team.php file in the Infinity Pro child theme for an example.
December 4, 2016 at 5:38 am #196965jaychan
ParticipantThank you @braddalton
Based on your suggestion, I found the function:
add_action( 'genesis_before_loop', 'ntg_do_query' ); function ntg_do_query() { global $query_string; query_posts( wp_parse_args( $query_string, array( 'orderby' => 'modified', 'order' => 'ASC' ) ) ); }
Is that correct?
Thank you.
December 4, 2016 at 6:43 am #196969Brad Dalton
ParticipantNo. Don't use query_posts.
Use WP_Query or even better, genesis_custom_loop
$args = array( 'orderby' => 'modified', );
See the page_team.php file in the Infinity Pro child theme for a working example you can modify.
December 4, 2016 at 7:18 am #196971jaychan
ParticipantI forgot to mention that I used Genesis Grid Loop: https://wordpress.org/plugins/genesis-grid-loop/
https://github.com/billerickson/Genesis-Grid/wiki
Could you please guide me how to archive the result without break the loop?
Thanks.
December 4, 2016 at 7:35 am #196972Brad Dalton
ParticipantDecember 4, 2016 at 7:39 am #196973jaychan
ParticipantYes, I first tried:
function genesis_grid_loop_args() { $args = array( 'orderby' => 'modified', ); }
and then:
function genesis_grid_loop_args() { $args = array( 'orderby' => 'modified', ); $query = new WP_Query( $args ); }
But none working! Did I miss anything?
Thank you.
December 4, 2016 at 7:42 am #196974Brad Dalton
ParticipantThat's not going to do anything.
What you need is a custom filter function written and tested
Or
Use a better method without the plugin.
Use column classes for the grid and pre_get_posts to modify the query.
December 4, 2016 at 7:55 am #196976jaychan
ParticipantThis reply has been marked as private.December 4, 2016 at 8:10 am #196977Brad Dalton
ParticipantCan't see PM's. Please email me if you need to send a PM [email protected]
December 4, 2016 at 8:39 am #196978jaychan
ParticipantThank you @braddalton
I tried to do it with Genesis loop but not successful. simplerthansimplest @WP.org just help me solve this. For anyone who need this later:
add_action( 'pre_get_posts', 'alter_query_to_show_modified_post_first' ); function alter_query_to_show_modified_post_first( $query ) { if($query->is_main_query() ) { $query->set( 'orderby', 'modified' ); } }
December 4, 2016 at 9:27 am #196981Brad Dalton
ParticipantDecember 4, 2016 at 9:33 am #196982jaychan
ParticipantYes, work with the grid. But now I see another issue!
I've many scheduled posts, when a scheduled post is published, it no longer display at top because the code check 'modified date' of scheduled post, not 'publish date'
Is there a way for 'latest modified' and 'latest post' to work together?
Thank you.
December 4, 2016 at 9:38 am #196988 -
AuthorPosts
- The topic ‘Front page displays latest updated post’ is closed to new replies.