I found the final answer here: https://wordpress.stackexchange.com/a/217534/77722
Page 2 of front page was taking pagination from main query, not from my custom query.
I’ve taked these actions:
1. To change name of front-page.php to index.php in order to get the main query every time page is loaded (even when paginated)
2. To change main query with pre_get_posts in order to show posts of my CPT:
add_action( 'pre_get_posts', function ( $q ) {
if ( $q->is_home() && $q->is_main_query() ) {
$q->set( 'posts_per_page', 1 );
$q->set( 'post_type', 'trabajo');
}
});
3. Do a normal loop in the index.php:
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
the_title();
}
}
wp_reset_postdata();
the_posts_navigation();
Works perfectly!
Related Posts:
- Custom post type archive 404’s with paginate_links
- Number of pages – multiple (custom) post types
- Custom permalink with pagination
- Related posts by author pagination not working on the production site
- Secondary loop pagination on custom post type single post gets redirected to first page
- Pagination Doesn’t Work
- Numeric pagination custom post type
- Custom wp_query pagination – next_posts_link() or wp_pagenavi() always empty
- custom post type paging not working past page 3
- WP_Query pagination using only numbers instead of /page/1 on URL
- Pagination not working
- Pagination Issue: Custom Post Type In Index
- Custom query form submission pagination
- Paginated Taxonomy Term Archive including one post per term
- Unable to get paginate_links working with a custom query [duplicate]
- Pagination on category page with custom post types
- How to add pagination to wp_query [duplicate]
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- Previous/Next Link by Meta Value in CPT
- Pagination for Custom Taxonomy Page [duplicate]
- Pagination on with query_posts in custom post type template
- Custom taxonomy rewrite give pagination 404
- Woocommerce search pagination not working
- How do you paginate a query grouped by month?
- Pagination issue on category.php using custom post type query
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- can these 3 queries be re-written as 1 query?
- pagination not working for category.php (custom post types in categories)
- Custom WP_Query always respond with 200 status even when no entry
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- Trouble with pagination
- Pagination 404 on Index with custom query
- Custom post type and custom taxonomy 404 on page 2
- Pagination for search results of custom post type [duplicate]
- Custom Post Type Archive Pagination
- All blog posts are not showing up
- Single parent post lists child posts with pagination
- Custom post type pagination error
- Previous / Next Links For Custom Post Type Sorted By Meta_Value
- custom taxonomy pagination 404 error
- Pagination in custom post type archive.php not working
- Pagination Not Working When Used With WP_Query() `offset` Property
- Numeric pagination custom post type
- Problems in paginate_links with custom query loop and MB-Relationships
- WordPress doesn’t respect Page slug in custom post type url pagination. Keeps getting removed
- Make pagination work as a carousel (custom query)
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- why custom post archive gives always no more than 10 posts despite of paging settings?
- query and paginate multiple post types
- Custom post type blog pagination conflict
- Custom post type pagination, single page issue
- Pagination always adding “Next” link when results come from Custom Post Type WP_query
- Paged within a custom content type template [duplicate]
- Pagination not working on homepage
- send user to first page of results when reposting to page?
- Fourth page of custom post type archive page does not exist
- Pagination broke after updateto WordPress 3.4 [duplicate]
- Archive page – problem with pagination
- Pagination not working with custom loop
- Pagination with custom loop
- How to query for posts (in hierarchical custom post type) that have children?
- Query for posts in 2 taxonomies
- How do I create an archive page for standard posts?
- Multiple post type queries (with specific arguments for each)
- Custom Post Type Loop within Shortcode
- Combining sorted and random CPT
- How to add post_type=value when editing that post type in the WordPress admin?
- Display CPT posts based on specific taxonomy
- Troubles with acf/save_post and WP_Query
- Query custom post type with ACF Date
- WP Query with categories only shows one post and ignores the category
- WordPress request fiter order by related post’s post_title
- Order Custom Post Type by Custom Field Value
- WordPress wp_query() basic question about args
- How to properly rewrite pagination rules for a CPT to avoid 404 error on /page/2
- $post->post_meta not pulling any post in wordpress/php
- How to get the post terms from a child taxonomy
- display posts of custom post type with custom taxonomy
- WP_Query get post from a category and from another post type
- foreach loop inside the loop creating duplicates in output
- Sorting by meta_key different to search criteria?
- How to fetch posts that are stored in the different table than (default) wp_posts?
- WP_Query order custom post type with certain meta key value by post modified date
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- WP Query: If field X is empty, show posts based on field Y
- Sort custom post column by generated value?
- meta query condition don’t work
- Custom Post Type Pagination getting 404 error
- How to search through all child taxonomies using WP_Query?
- Custom post type category returns null
- Tell wordpress to show a single page instead of an archive page
- How to get post by meta value
- minimize wp_query call to database
- sorting in wp query based on custom field value
- Only show current category post
- Query Posts From Multiple Post Types
- Pagination not working with custom loop
- querying to custom field over ACF REST API
- Display ACF object field data using Elementor Custom Query
- Sort ACF by custom taxonomy