-
erickimani
How do I go about making changes to the categories page on generate press.
-
Fernando
Hi Erickimani,
What sort of change are you looking to make? Are you wanting to change how posts appear for instance? If so, this article should help: https://docs.generatepress.com/article/block-element-content-template/
-
erickimani
https://share.getcloudapp.com/qGu61no7
Sorry this link doesnt seem to be helpful when I click it. Is it the correct one
-
Fernando
Sorry, I pasted the wrong link. I corrected it now. Can you check my response above?
-
erickimani
Thanks for this.
I would like to be able to get teh categories to be orded according to modified date but I dont see where to set this up
This is teh setup I have ont he element
-
Fernando
Try adding this snippet:
function my_custom_ordering( $query ) { if($query->is_main_query() AND !is_admin() ) { if ( $query->is_home() || $query->is_category() || $query->is_tag() ){ $query->set( 'orderby', 'modified' ); } } } add_action( 'pre_get_posts', 'my_custom_ordering' );
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
-
erickimani
thanks
-
erickimani
For taxonomies I created such as this one called regions, it didt work. Text is still showing
Take a look
-
Hi there,
Custom taxonomy archive is not included in the PHP code, you can modify the code to this:
function my_custom_ordering( $query ) { if($query->is_main_query() AND !is_admin() ) { if ( $query->is_home() || $query->is_category() || $query->is_tag() || $query-> is_tax() ){ $query->set( 'orderby', 'modified' ); } } } add_action( 'pre_get_posts', 'my_custom_ordering' );
-
erickimani
Sorry it doesnt work I am getting an error message
-
David
Hi there,
that means you have more than one snippet that uses the same function name.
Change Yings latest code to something different ie.function my_custom_ordering_two( $query ) { if($query->is_main_query() AND !is_admin() ) { if ( $query->is_home() || $query->is_category() || $query->is_tag() || $query-> is_tax() ){ $query->set( 'orderby', 'modified' ); } } } add_action( 'pre_get_posts', 'my_custom_ordering' );
- You must be logged in to reply to this topic.