You shouldn’t be using a custom query for a post type archive page. Pagination being difficult is one of the reasons. If you want to change your post type archive to sort by a custom field, hook into pre_get_posts
to modify the main query:
function wpse_282839_post_type_order( $query ) {
if ( ! is_admin() && $query->is_post_type_archive( 'restaurante' ) ) {
$query->set( 'posts_per_page', 4 );
$query->set( 'meta_key', 'destacado' );
$query->set( 'orderby', 'meta_value' );
$query->set( 'order', 'DESC' );
}
}
add_action( 'pre_get_posts', 'wpse_282839_post_type_order' );
Then just use the normal loop and pagination links in your archive template.
Related Posts:
- How to display custom post type pagination buttons when processing AJAX request
- Displaying custom field according to date
- can these 3 queries be re-written as 1 query?
- Custom post type pagination – always return first page
- How to set the seo title tag on a page by page basis?
- WebP Fallback for Inline Background Image in Style Attribute
- pagination not working for category.php (custom post types in categories)
- Adavnced custom fields relationship query plus query inside
- Query based on custom fields start and end date
- How To Import CPT With Only Few TEXT ACF Fields From Front End?
- Custom post type pagination 404
- Advanced custom field boolean value in custom post type
- Why is my WP Query not returning first result’s post meta?
- Pagination broken by naming conflict between CPT and Page
- Cant get paginations on single.php to work with my custom post types
- Number of posts in the archive
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Pagination custom post type not working with rewrite slug
- Pagination Not Working for Custom Taxonomy with Custom Query – 404 Error
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- Querying & displaying custom post type into an existent page [closed]
- Pagination Error : Duplicate argument being outputted
- How to get a custom type post data when it has a connection with another custom type post?
- Custom post type showing same Post on all Pages
- Custom WP_Query always respond with 200 status even when no entry
- Why would social icon badges disappear after adding a custom post type?
- Sort a custom post with ACF: Date Picker & Display Featured!
- Can’t use pagination with custom taxonomy
- ACF repeater field usage
- List of users that clicked a ‘Join’ button at single post
- 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
- Post loop count is not in order
- previous_post_link in same taxonomy in custom post type
- How to do admin CRUD & Pagination
- How to inherit field value from parent post into in child / sub post
- How can I add a shortcode to query Custom Post Type with ACF in WordPress?
- Custom ordering of CPT items not matching with the ordering of its pagination
- Custom Post Type page sorts differently on different environments
- Postname on unique permalink structure appends “-2” for a custom post type. How can I get this to stop happening?
- set_query_params using custom params defined in functions file?
- Custome fields not displayed
- Pagination doesnt work in custom post type
- Create short URL with auto 301 redirect
- ACF for custom post type archive pages: which hook to use?
- Pagination hitting 404 page on /page/4
- How to define the template for custom posts?
- Batch Extract Date from post title and put into ACF custom field
- Query entries from custom post type in an ACF flexible content field
- Why is wp api returning old acf values?
- How to use single.php for creating, reading and editing Custom Posts with ACF
- Break up posts per page in two sections
- Distribute Custom Post in different pages
- get custom post type value in header.php [closed]
- Custom post type and custom taxonomy 404 on page 2
- posttype and custom fields on multisite
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How do I replace the post title with a custom field?
- Advanced custom fields Post Object image field not displaying in custom post type single.php
- Using Pagination for Custom Post Type and keeps returning 404
- Sum and count of custom field values
- Pagination on search results page
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- 404 Page Not Found on /Page/2/ on Tag Page
- How to list custom post types on a custom post type page?
- How to export custom post type with ACF to individual file with automation?
- Custom fields not showing in custom post type
- Pagination for search results of custom post type [duplicate]
- Group by custom field value (start and end times)
- Custom post types, disable fields
- meta query not retrieving posts
- Custom Post Type with Configurable Sidebar via ACF
- Pagination of custom post type leads to 404 error
- Pagination for custom post types – url rewriting
- Custom Post Type Archive Pagination
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis
- next page with custom post
- ACF Relationship Posts how to show additional content
- wp-includes does not contain a feed template
- Difference between page and paged
- Taxonomy rewrite pagination 404
- Using WP meta query to show custom post types by a start and finish date
- Limit search field to just search a custom post type with custom fields
- Advanced custom field – posted fields from custom post type
- All blog posts are not showing up
- Custom post pagination trouble
- Excerpt length: get first paragraph
- SQL query – get ids – Advanced Custom Fields / WPeC
- Pagination on a page
- Custom field with Types: get custom field’s value label (of type select)
- Custom Post Type Pagination on Single.php?
- Single parent post lists child posts with pagination
- Using custom post type as front home page pagination not working
- Custom Post Type, Pagination and 404s?
- Custom post type pagination error
- 2 custom post type paging in 1 custom taxonomy
- Pagenavi Plugin and Custom Post Type – Multipage results
- How to display author details in a custom post type in the wordpress backend?