Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // see https://kriesi.at/support/topic/how-to-customize-the-author-page/
- // 1. Configure layout and settings
- add_filter( 'avf_author_loop_args', function( $atts, $context ) {
- if( $context == 'author' ) {
- $atts['type'] = 'grid'; // 'grid' or 'list' Layout
- $atts['columns'] = 4; // Columns count
- $atts['image_size'] = 'gallery'; // image size
- $atts['contents'] = 'excerpt_read_more'; // Content-Type
- $atts['items'] = -1; // Posts per page
- $atts['paginate'] = 'no'; // Pagination on/off
- $atts['show_modified_date'] = 'yes'; // 'yes' = shows "Updated: XX"
- $atts['orderby'] = 'title'; // order by : 'date', 'modified', 'title', 'rand', 'comment_count'
- $atts['order'] = 'DESC'; // order : 'DESC' (neueste/Z-A) oder 'ASC' (älteste/A-Z)
- $atts['fallback_image'] = 'placeholder'; // URL to the fallback image, 'placeholder' for svg inside a gray background - or:
- // $atts['fallback_image'] = get_stylesheet_directory_uri() . '/images/fallback-image.jpg'; another possibility: upload a fall-back image
- }
- return $atts;
- }, 10, 2);
- // 2. IMPORTANT: Adjust query for pagination and sorting
- add_action( 'pre_get_posts', function( $query ) {
- if( ! is_admin() && $query->is_main_query() && is_author() ) {
- // Get the filtered arguments
- $default_args = array(
- 'items' => get_option('posts_per_page', 12),
- 'orderby' => 'date',
- 'order' => 'DESC'
- );
- $atts = apply_filters( 'avf_author_loop_args', $default_args, 'author' );
- // setup for Query-Parameters
- $query->set( 'posts_per_page', $atts['items'] );
- $query->set( 'orderby', $atts['orderby'] );
- $query->set( 'order', $atts['order'] );
- }
- }, 1 );
- // Example: Different layouts for different authors
- /*
- add_filter( 'avf_author_loop_args', function( $atts, $context ) {
- if( $context == 'author' ) {
- $author_id = get_query_var( 'author' );
- // Individual configuration for specific authors
- if( $author_id == 1 ) { // commonly the Admin
- $atts['type'] = 'grid';
- $atts['columns'] = 3;
- $atts['contents'] = 'excerpt_read_more';
- } else {
- $atts['type'] = 'grid';
- $atts['columns'] = 4;
- $atts['contents'] = 'title';
- }
- }
- return $atts;
- }, 10, 2);
- */
Advertisement
Add Comment
Please, Sign In to add comment