Problem solved,
I’ve used this:
$d=new WP_Query(
array(
'category__in' => array(4),
'post_type' => 'post',
'posts_per_page' => '-1',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'data',
'value' => $t,
'compare' => '<='
),
array(
'key' => 'data',
'value' => $o,
'compare' => '>='
)
),
)
);
Instead of the other one before, and everything is working fine.
Related Posts:
- Automatic value for custom fields for posts
- WP_Query orderby not working with meta_value_num and menu_order
- How can I sort posts by the date and a custom meta field?
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Query Posts With Over 1000 Views
- Query Posts by Custom Field
- WP_Query custom field pass the post id
- Override WordPress core post-template.php block template
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- WP_Query sort by meta_value_num or date
- Creating Ordered Query using Meta_key
- Order posts by separate menu order for different sub-categories
- Image inside the content is replaced with featured image from my older post
- Accessing the post content with WP_Query
- Update all posts automatically when using post_meta
- Add custom field to all posts in specific category
- meta_box or custom_field as a second tinymce post-instance?
- Get only modified posts
- Create A Metabox For A Custom Field
- How to output comments number of a post per day?
- Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?
- If specific user role then sticky post
- How to add a custom field after wp post
- Custom fields on a virtual page
- Display posts with comments closed, with pagination?
- What Is meta_id In wp_postmeta?
- Get a custom field of all posts on current blog page
- Only display posts after current date
- I want to query posts in monthly basis
- Custom WP_QUERY $args
- Improving WP_Query for performance when random posts are ordered
- Why won’t my taxonomy query show up?
- Limiting the number of posts in WP_Query leads to unexpected result
- Guest Author – How to display posts on /author/ archive page
- WP_Query with ajax handler returns the same posts
- How to insert 2 args into 1 Wp_Query for a slideshow
- How to do set post permalinks using 6 digit random unique function?
- posts_per_page option limits the number of Gallery items
- Why Query is returning empty array?
- meta_value timestamp older than now
- Get posts with multiple categories
- Do not show children of a category
- Create a list of posts with topic headdings
- Add field to user meta table in database when link is clicked
- Hide custom metabox value from custom fields
- Query for first 3 posts to change the look and feel
- Getting blog pagination to work on page set as front page
- search blog posts by author first name and or last name
- if in category but only with post meta
- unique post in “$args” of wp_query display more than one post
- Display current post position in Elementor Posts widget
- How to give classname to post if post has no content?
- Custom wp-query in wordpress rest api
- Saving Post Data in Another Database
- posts_per_page returning only one post
- Need to know custom code to display random and most viewed posts in wordpress posts and pages
- How to retrieve certain number of images from a wordpress post?
- WordPress post filter menu
- After ajax image is outside the “ tag
- How to display post list in a table layout (multiple queries in single loop)
- Edit custom fields in posts list
- Current and next month posts
- If custom field is empty, use one from a previous post
- Get latest author posts inside the loop
- Same post appears in related Posts?
- Why my meta boxes won’t show in front post page?
- Automate post update for all posts?
- WP_Query outputs wrong post in custom post type
- Post meta not working
- how to show comments only author which send own posts in wordpress
- Group first, 2nd, 3rd, etc posts by category terms
- Adding an option to post editor to show a site disclaimer or message
- How to sort WP_Post Object array by object field in php?
- Order by meta_key field in WordPress not meta_value field value
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- How to create page with post content in it?
- How to remove a post from results by ID after query?
- How do I display posts ordered by a date custom field?
- Override wp_link_pages pagebreak with filter
- WP_Query extended with AJAX
- Is it possible to query a category with specified posts?
- Extracting a TLD from the content and assign to custom field
- Blog only showing one post even though more published
- WordPress loop uses unmodified posts array, why?
- How to retrieve a post by inputing the url in a custom field and displaying it on an options page
- Sort / Filter Queries
- Custom fields in normal posts
- Query to get data of a post, if in category?
- Order posts by custom field
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Remove duplicated posts in the loop if post has more than one category
- Why I getting only 1 post?
- The next_posts_link() works only with original $wp_query
- get_post_meta property of non object
- Limit amount of pages shown in pagination within wp_query
- First post in loop displays twice
- How to make a local “scroll to ID” on post?
- Read more opens attachment
- Get related posts matching most of the provided tags using WP_Query
- WP_Query post_tilte search in posts table