trellmip
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Unfortunately, this does not seem to work. I set up the twentytwentywo theme and made the author.php file be only this code but the pagination still doesn’t work.
<?php function my_cptui_add_post_types_to_archives( $query ) { // We do not want unintended consequences. if ( is_admin() || ! $query->is_main_query() ) { return; } // Check if we're on an author archive. if ( is_author() && empty( $query->query_vars['suppress_filters'] ) ) { $cptui_post_types = cptui_get_post_type_slugs(); $query->set( 'post_type', array_merge( array( 'post' ), $cptui_post_types ) ); } } add_filter( 'pre_get_posts', 'my_cptui_add_post_types_to_archives' ); $args = array( 'post_type' => array( 'post', 'my_custom' ), 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC', 'page' => get_query_var('page') ? get_query_var('page') : 1, // use page parameter for pagination 'post_status' => 'publish', 'author' => get_query_var('author'), ); $query = new WP_Query( $args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?> <h1><?php the_title(); ?></h1> <?php endwhile; // add pagination echo '<div class="pagination">'; echo paginate_links( array( 'total' => $query->max_num_pages, 'current' => max( 1, get_query_var( 'page' ) ), ) ); echo '</div>'; wp_reset_postdata(); else : echo '<p>No content found</p>'; endif; ?> <?php get_footer(); ?>Am I not inserting it where it should be going? Thank you for the help so far.
Thanks. Yes, I am trying to merge multiple post types into an author archive page. I figured there must be something weird going on with
paginate_linksbecause nothing I was writing for the loop was working.If you could provide me a
pre_get_postssnippet, that would be much appreciated.
Viewing 2 replies - 1 through 2 (of 2 total)