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
- Filter by custom field in custom post type on admin page
- Pagination throws 404 error on custom taxonomy archive pages
- Pre get posts for single post
- Filter a custom field based on selection of another custom field (ACF) [closed]
- Pagination not working with custom category template
- Custom Post Type pagination – normal solutions aren’t helping
- Custom Post Type Archives by Date (stored as meta value) WP3.1
- Pagination Doesn’t Work
- Numeric pagination custom post type
- Posts in Multiple Columns and Rows with one single loop
- Retrieve a specific field from taxonomy term through advanced custom fields [closed]
- Paginate Custom Post Type Page
- Pagination not working
- Pagination Custom post type
- Pagination Issue: Custom Post Type In Index
- Display posts if a custom field value is equal to another custom field value
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- Pagination problem
- Custom post type archive not regarding ‘posts_per_page’ => -1
- Unable to get paginate_links working with a custom query [duplicate]
- Setting posts per page in query_posts
- ACF simple text field value not showing
- Post Object Filter by Custom Field, not title (ACF)
- Rewrite WordPress URL to show CPT meta field data
- Pagination for custom php code
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- Pagination on a custom post type loop
- Page vs Custom Post Types Differences/Issues
- Custom taxonomy rewrite give pagination 404
- WP_Query order by custom field, then randomly order some of results
- Next and Previous Posts of Same Parent
- Custom template Page 2 not working
- custom post type pagination error 404
- Next Post links not working in custom post type shortcode
- Custom Post Types vs. Advanced Custom Fields (with Repeater Field add-on)
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- Specific routing for CPT
- How To Import CPT With Only Few TEXT ACF Fields From Front End?
- Advanced custom field boolean value in custom post type
- Cant get paginations on single.php to work with my custom post types
- Custom WP_Query always respond with 200 status even when no entry
- Why would social icon badges disappear after adding a custom post type?
- Can’t use pagination with custom taxonomy
- List of users that clicked a ‘Join’ button at single post
- Pagination 404 on Index with custom query
- Custom ordering of CPT items not matching with the ordering of its pagination
- set_query_params using custom params defined in functions file?
- How to define the template for custom posts?
- Query entries from custom post type in an ACF flexible content field
- 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 Post Type Archive Pagination
- Limit search field to just search a custom post type with custom fields
- Custom field with Types: get custom field’s value label (of type select)
- Custom post type pagination error
- Previous / Next Links For Custom Post Type Sorted By Meta_Value
- Show posts associated with ACF post object and custom post type
- Custom archive page for custom taxonomy and pagination issue
- Create if else for post types in WP_Query ‘post__in’ values
- Custom post type paging return home page
- CPT email notification including only new value custom fields
- pagination problem listing custom post types of taxonomy in wordpress
- Save_post acf data not updating category of post type
- Display Specific Posts at Start of Loop
- Permalink for custom post type pages not working
- Adding specific custom fields (images) to post excerpt
- filter using custom fields
- Pagination for custom query returns 404
- Pagination with a custom post type
- CPT: execute code after load if parameter is set
- next_posts_link() always generates second page link on custom post type
- Values show up in custom home page but not in custom post pages
- Display related post content and custom field content
- Pagination functions won’t work
- pagination for a custom query
- How to load custom post type plugin after acf options page (or get settings from there another way)?
- How to Fix Custom WordPress Loop with Pagination on Single Post View?
- why custom post archive gives always no more than 10 posts despite of paging settings?
- Filter Content on all Post Types
- $post breaking container loop
- Pagination in custom loop for custom post type throwing 404 error
- Pagination for a Custom Taxonomy
- Collection of fields in a single post
- WordPress Load more posts by ajax not working
- Pagination for event query
- WordPress custom post type post and category links 404
- Pagination not working for archive
- Archive page – problem with pagination
- Pagination not working
- using a template for more then 1 page
- Retrieve a post with its ACF repeater fields in wordpress
- Pagination on category pages using wp_pagenavi causes 404 errors
- CPT Archive Pagination – Page not found
- Filter page ID outside the loop and order
- the_post_navigation in single page with multiple taxonomies
- Elementor Custom Query to get Posts by ACF (Post Object Field
- Custom taxonomy meta fields
- Custom Sort Order for Custom Post Type Taxonomy
- WordPress post objects in one parent post object