In the members-only forum a user asked:
Hi Sridhar!
The Genesis Author Pro plugin by default shows the books in the library in newest to oldest order, I’m wondering if there’s a way to reverse that so that the oldest book (or first added) is shown first and so on?
Also, is there a way to show the books’ tags and/or series under each book in the library?
Thank you so much for all your help!
pre_get_posts
action hook can be used to display the books in ascending order of their published date by adding the following in child theme's functions.php:
add_action( 'pre_get_posts', 'sk_change_books_order' ); | |
/** | |
* Change display order of books on the archive from DESC to ASC | |
* | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/customize-the-wordpress-query/ | |
* @param object $query data | |
* | |
*/ | |
function sk_change_books_order( $query ) { | |
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'books' ) ) { | |
$query->set( 'order', 'ASC' ); | |
} | |
} |
Genesis Author Pro plugin comes with a function to display the series and tags. We can copy the books CPT archive template from plugin directory to child theme directory and modify it to call this function.
Copy wp-content/plugins/genesis-author-pro/templates/archive-books.php to the child theme and replace all its content with the following:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Thank you so so much for this Sridhar! Works perfectly 🙂
One last question – do you know if there’s a way to modify / customize the books’ entry meta so the “Tagged with:” / “Series:” text doesn’t show? Thank you!! 🙂