As hinted by the comments I replaced the query_posts by a WP_Query query.
$args=array(
'post_type' => 'restaurante',
'posts_per_page' => -1,
'meta_key' => 'restaurante_municipio',
'orderby' => 'meta_value',
'order' => 'ASC');
$the_query = null;
$the_query = new WP_Query($args);
if ( $the_query->have_posts() ) {
$total_results = $the_query->found_posts;
echo '<p><b>Restaurantes: '.$total_results.'</b>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
...
..
.
}
}
wp_reset_postdata();
Now it is working
Related Posts:
- Pagination not working with custom loop
- Custom Taxonomy’s Label to change the text appearing in Appearance > Menu
- Breadcrumbs with Custom Post Types?
- order by meta_value serialized array
- How to query for posts (in hierarchical custom post type) that have children?
- bulk Update post_meta with default values
- Running a function on post content and CPT meta
- Get the post_type of current taxonomy or category page
- Output the slug and name of a CPT single post taxonomy term
- Slug for standard post post_type
- WordPress custom post type archive with description
- Custom post types – show specific posts
- Paginate_links links not working accordingly to how I do query the page
- Add management screens to post type
- Updating post title using wp_update_post
- Remove parent from custom post type
- Metabox Populated with a Custom Post Type – How to Output CPT based on Select?
- Associate custom post types with normal posts
- Troubles with making a custom template for posts
- Custom Post Type and Labels
- related posts – pulling tags from a specific post type
- WP 3.0.5 – Custom posts matching 2 taxonomies
- 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?
- Change archive page template using pre_get_post
- Force documents to appear in Featured Image dialogue
- hide a certain custom field
- Query with no terms uses index.php template instead of archive.php
- Sort by alphabetical order archive.php page
- custom taxonamy and post type
- Custom post type archive page – Posts overview – with one modal for multiple posts?
- Getting categories of posts under a custom taxonomy
- Is it possible to to use custom post type types on a page with the same slug somehow?
- Custom Post Fields at the beginning of a Custom Permalink
- Add term to custom post type on draft
- When an unregistered user submits a form for a custom post type, send an email that lets them delete their post
- Custom Post Type Category Link
- get_page_by_title() doesn’t retrieve my post
- Show all tags on custom post type
- Specifying meta field’s column type in Database using add_post_meta
- show custom value from frontend form in a post (custom post type)
- Front end access to a SQL data repository – recommended way?
- Merge page with custom post type
- FacetWP paging custom wp_query
- why post_class() function apply css classes to all other files?
- Looping Through Categories of a CPT
- What is the diference between Post Metadata and Queried Object
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- custom post type make featured image box full width
- Cannot get custom posts by category
- Search for dates on custom post types
- Convert Custom Table Data Based Plugin To Be Searchable
- Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?
- list posts of two post types in a single template
- Control Loop Within Loop
- Multiple post types for BuddyBlog plugin [closed]
- Sets post_parent in custom post type posts automatically based on cpt->page name
- How to filter Multiple taxonomies with radio buttons
- Custom Post Type Date Based Archive URL rewrite [duplicate]
- Restrict access to custom post type based on its taxonomy terms
- Create loop from selected terms in ACF taxonomy field
- Custom rewrite rule based on other custom post type title
- Sending current featured image to email
- Display CPT Category List as Shortcode
- Custom post type sortable columns when column value is from a custom database value
- Correct way adding External classes to Custom Post type and output their methods to template
- Linking WordPress Post Types to Another
- Assign a Post to a User
- Migration in new Custom-Post-Type-Structure
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Place a button besides “add new”
- Custom Archive – hide posts until a search is made?
- Use WP pagination functions on a custom page template
- How to get all posts assigned to a taxonomy term only?
- How can I save a Custom Post Title and Slug with a Custom Field?
- Custom Template for CPT Categories
- How to implement custom post type’s users
- Generating excerpts from a custom post type to display in a Widget
- Do not output category and tag URLs
- Changing some of the language within the revision viewer admin page revision.php
- How to pass taxonomy terms to WP_Query along with $args?
- Custom post type URL returns 404 error page
- Programmatically Split A Post Into Multiple Pages
- Bulk remove category from custom post type?
- Custom Post Types (Changing post style based on category)
- Hide custom post type and use its slug in new plugin menu
- Page template anomaly
- Structure of custom post type / taxonomy?
- Notices when submitting custom post type from front-end
- Issue On Listing Woocommerce Parent Tag List
- show custom post’s post in two different divs [duplicate]
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- Creating post custom field text area
- Send email on creation of custom post type and use get_post_meta()
- Can I add a wordpress page using the slug for a CPT rewrite
- YARRP related posts with custom post type and wp-graphql
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- WordPress does not show the custom fields box
- Create a hierarchical list of posts that’s grouped and nested by category