Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Filtering by multiple conditions in the loop

You cannot mix array syntax and string syntax in the same argument. If you start with array syntax, you should stick with that, the same applies if you start with string syntax, then you should stick with string syntax. Because you are using post__not_in which is an array, you should stick with array syntax

<?php $query = new WP_Query(
    array(
          "post__not_in" =>get_option("sticky_posts"), 
          'paged' => get_query_var('paged'), 
          'meta_key' => 'Sortdate',
          'orderby' => 'meta_value',
          'order' => 'ASC'
       )  ); 
 ?>

Related Posts:

  1. How to order posts tag by tag?
  2. Use REGEXP in WP_Query meta_query key
  3. Order by optional meta key?
  4. How to list some posts first in the loop based on post id
  5. How to get order of posts?
  6. Order posts by ID in the given order
  7. What is the most efficient way of querying posts based on visits and date for current day?
  8. Query Custom Meta Value with Increment
  9. Show all parents and children in custom post type in right order
  10. WP_Query Order by Specific Post ID First
  11. How do I run through a WordPress loop called from a filter function?
  12. Order by title without taking into account ‘the’
  13. Order by empty custom field
  14. How to order posts by title after they have already been sorted by category
  15. New WP_Query loop in admin causes problems
  16. WP Query – order posts by meta field first and then order the rest
  17. How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
  18. Orderby two meta fields not working
  19. relation OR instead of AND – Filtered term ID’s in loop
  20. WP_Query orderby random do not repeat infinite scroll – one loop
  21. Why does apply_filters behave different inside and outside a loop?
  22. show most viewed post
  23. update_post_meta() not updating
  24. How to order posts, that have already been filtered by custom taxonomy, by their category names?
  25. WP_Query doesn’t works inside loop
  26. Display three sequential posts on each page load, without repeating previous
  27. Sort by meta key within same day
  28. Add filter to Orderby Parameter using Array
  29. Order by multiple meta keys on wordpress
  30. loop through custom post types with meta data
  31. Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
  32. View related categories in order of posts
  33. modifying the loop multiple times with arguments passed through ajax to wp_query
  34. WP_Query causing links to not work
  35. Order posts by more than one variable (meta_key and publish date AND time)
  36. Create custom order sortby based on array of id
  37. Fetch only categorized posts
  38. get_post_meta for Custom Post Type ( CPT )
  39. Continue loop after $queryObject
  40. query_posts() doesn’t seem to be called in my page
  41. WP Meta Query at depth 2
  42. Some doubts about how the main query and the custom query works in this custom theme?
  43. display post multiple times based on array of dates
  44. Best way to Order Post in Home without a plugin
  45. Retrieving category pages from subcategory returns empty sets
  46. orderby in WP_QUERY – Use the order from the Dashboard
  47. How to make a wordpress loop file that displays posts based on certain conditions
  48. active link for most recent post on vertical tabs
  49. 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
  50. WP_Query with child element
  51. Pagination returns 404 after page 20
  52. Problems with WP_Query, Loop, a condition and Posts per Page
  53. Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
  54. Query All Attachments and Order by Parent Publish Date
  55. Ordering Posts by parent category, name ascending
  56. WP_Query secondary query failing
  57. custom query – offset to pagination
  58. WP_query for posts with same post type AND same post category
  59. Order Custom Field by Price
  60. How to solve this script problem in theme directory?
  61. Custom query with post_class filter using current_post not working
  62. WP_Query Posts by Metadata from Option Tree
  63. Custom loop – Isolating post meta output depending on current query taxonomy terms
  64. WP_Query a custom field value bringing back 0 results
  65. Set Transient on CPT
  66. Sorting Posts with meta value not working
  67. Issue in If else condition [closed]
  68. Create multiple sections for all categories and then queries all the posts for each of those categories
  69. Pagination not working with WP_QUERY
  70. Using orderby with 2 meta keys
  71. Show posts in category
  72. Both WP_Query and get_posts returning 1 post
  73. Custom search (wp query by custom fields)
  74. Order posts by custom column using pre_get_posts
  75. Iterate through ID’s in loop
  76. How to get several fields from wp_query?
  77. Sorting is not working in WordPress WP_Query
  78. Add custom WP_Query after the first 3 posts
  79. Load 3 posts in flexslider slide [closed]
  80. Loop through multiple custom fields with increasing number
  81. WP_Query for attachments without duplicating post_parent and displaying tagged image
  82. Different number of posts showing in development vs production server
  83. Issue with WP_Query (need a array of selected ID’s)
  84. Order WP_Query results in order other than ASC or DESC
  85. How do I display posts with specific value in a custom field into my loop?
  86. Show sticky post before other WP_Query
  87. WP Query to order posts by multiple meta fields
  88. List ALL posts within last week from current category on category page
  89. Return a single custom post from multiple meta queries
  90. Custom query to order by multiple taxonomies
  91. An archive page without post format (just standard post)
  92. Filter WP_Query output before it is accessed (pre_get_posts)?
  93. Custom post type archive organized by category
  94. Custom Search Query – include only custom fields and title
  95. Limit the number of posts from a specific category on index.php
  96. wp_query display posts based on day
  97. Multiple wp_query loops showing first 5 posts on all pages instead of older posts[Resolved]
  98. Sorting Posts Based On Meta Value Using AJAX
  99. Sorting: custom query with orderby meta_value_num THEN by title
  100. query_posts with sorting on a custom datestamp
Categories wp-query Tags filters, loop, order, post-meta, wp-query
Performance testing a WordPress site locally?
Custom Post Type Archive Pagination

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress