Exactly what @Pieter Goosen said. Not only are you creating havoc for WordPress, you’re adding unnecessary load on the server by introducing more queries on top of the main query:
function wpse_176933_custom_authors_archive( $wp_query ) {
if ( $wp_query->is_main_query() && $wp_query->is_author() ) {
$wp_query->set( 'posts_per_page', 4 );
$wp_query->set( 'post_type', 'publikasjoner' );
$wp_query->set( 'meta_key', 'rapportnummer' );
$wp_query->set( 'orderby', 'meta_value_num' );
$wp_query->set( 'order', 'DESC' );
}
}
add_action( 'pre_get_posts', 'wpse_176933_custom_authors_archive' );
Add this hook to your functions.php
, remove any custom queries from author.php
, and replace your custom loop with the main loop functions (the_loop()
, the_post()
etc.).
Related Posts:
- Pagination only won’t work in author template
- Find out total number of pages in global query on archive page?
- Multiple WP_Query loops with Pagination
- WordPress Pagination Not Working – Always Showing First Pages Content
- get_query_var function not working at all
- get_query_var( ‘paged’ ) not working outside of homepage
- Pagination returns 404 after page 20
- paginate_links() adds empty href to first page and previous link
- Combining two wordpress queries with pagination is not working
- Pagination with WP_Query is buggy – working for some pages, but not the others
- Get the number of posts from the current page results
- WP_Query and Pagination on a Static front page
- next_posts_link not working for loop called with ajax
- Pagination custom query
- Pagination/infinite scroll with WP_Query and multiple loops
- WP_query and pagination?
- pagenavi with merged wp_query [duplicate]
- Add and in the header while looping over custom query in page template
- Pagination not working on static page
- ‘paged’ in wp_query doesn’t work
- Display different number of posts from one category on the different pages
- Pagination not working Search posts
- WP Query with offset breaks wp_pagenavi or any pagination
- Transient pagination not working properly
- Injecting content with $wp_query->current_post restarts from zero on paged pages. How to inject content after X posts, regardless of pagination?
- Woocommerce custom loop to show all the products [closed]
- Merged two WP_Queries, posts per page and pagination not working
- Intentionally exceed max_num_pages on main query without getting 404?
- Pagination 404 errors for author posts query on author.php
- WordPress pagination link always leads to home page
- Pagination problem after WP_Query with tag filtering
- Pagination stops at page 6
- Paginated HTML Sitemap
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- Pagination is broken and I need help fixing it
- Pagination of a WP_Query Loop in a child-page page template
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- Five posts from a category in footer
- paging in WP_Query on static page
- wp_query ‘s’, search filter with pagination is not working
- pagination with numbers for WP_User_Query
- Cutom wp_query for geolocation search, pagination not working
- Pagination inside of a edit page
- Avoid repeated post on page 2 when excluding one on page 1
- WP Query to have sticky posts first, with pagination and having a joint ‘posts per page’ arg with main loop
- Pagination on static Posts page
- How do I get my custom query to work with search results after the first page?
- How to cache wp_query with pagination using transients?
- Removing duplicate values between two wordpress queries
- wp query error while paging the posts
- Include latest author posts with pagination in single template?
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Pagination on template page for custom query redirecting to index.php
- Get user posts with custom WP_Query on author.php
- Yoast primary category query modification
- Pagination in html table is not working
- Paging + WP Query
- WP_Query custom order and pagination
- Unable to paginate a custom page query
- Query Not working as expected
- WP_query paged pagination with excluded category still counts it
- max_num_pages says 4, yet I am only able to navigate to the third page
- Paginate pages with dynamic query
- Determining what post is displayed out of total posts found
- Trouble Making WP_Query paged
- Why is my pagination /page/2 taking me to index.php?
- paginate_links appearing on page but it doesn’t actually paginate – pagination on a static page with a dynamic `post_type` argument on a static page
- WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination
- WP_query pagination on frontpage
- Pagination unique to a widget
- Pagination inside the blog page not working
- Why pagination is not working with tax_query param?
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- Pagination Shows Up But Won’t Work on Custom Gallery Page
- Custom Query Pagination not working on static front page
- Showing the correct number of posts_per_page when avoiding the use of post__not_in
- How to set up pagination for a custom loop on a global template (author.php, tag.php, archive.php?)
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- Pagination returns 404 after page 20
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- Pagination is not working on custom query inside a custom home page template
- Horizontally paginate through sets of blog posts?
- Pagination error WordPress multiple loop
- Comments orderby comment date not working
- Switched from query_posts to wp_query, pagination no longer working
- Pagination With Custom WP Query not functioning
- Ordering Custom WP_Query loop by meta key value with pagination
- Query specific number of posts for each post type in specific order
- Loop being strainge
- Custom query (author is post_author or meta co_author) with Pagenavi pagination
- Pagination in custom query not working [duplicate]
- paginate_links() on page (shortcode output)
- WordPress Post Looping? [duplicate]
- Pagination showing same posts despite changing page
- error with $query->have_posts()
- Pagination on custom post type not working
- Search results stuck on page 1
- Pagination only showed when no category is set in wp_query
- taxonomy-{term}.php terms pagination returning 404 after a certain page