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

is_main_query() never called on WP 4.4

The action hook pre_get_posts is called well before the page template is rendered. Move add_action('pre_get_posts', 'my_pre_get_posts'); and your my_pre_get_posts() function to your theme’s functions.php file.

Related Posts:

  1. Custom Queries: Joining On Meta Values From Two Custom Post Types
  2. Automatically adding meta data to posts or multiple query help
  3. WordPress Orderby Numeric Value Not Working
  4. Returning a custom content types with meta values
  5. Linking posts together with Advanced Custom Fields “both ways”
  6. meta query always fails even if data is correct
  7. Retrieve post data via WPDB class
  8. What’s the equivalent of Hide From Menus on MODX on WordPress?
  9. Custom filter function not working with Custom post type
  10. WP_Query orderby and tax_query
  11. I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
  12. Displaying Posts from Custom Post Types
  13. Different Ways to Query Custom Post Types?
  14. Importing Data from a Non-WordPress database, into WP
  15. Getting thumbnails of a custom posts featured images in a page-templates metabox
  16. How to organise this data within WordPress
  17. List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
  18. Remove Post Custom Meta Box
  19. Can’t publish custom post type – “You are not allowed to edit this post.”
  20. Custom post type posts don’t show in archive widget
  21. Custom fields for custom post type
  22. Show future events based on custom field AND order by date
  23. Showing specific post in order of array wp_query
  24. Meta Data for Custom Post Type not saving
  25. Using preg_replace to filter custom textarea
  26. Check if post with same meta value exists
  27. Filter date from post meta when date is in string format
  28. Get only used meta_values
  29. If Post Meta Equals Current Title Conditional Advanced Custom Fields
  30. Is there a way to exclude posts based on meta_values?
  31. Number of posts in the archive
  32. Query of custom post types only shows first post
  33. Custom query for custom post_type
  34. Adding custom field values to wp_list_pages
  35. Query multiple taxonomies with pre get posts
  36. How to query 2 custom post types that need to share a slug?
  37. Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?
  38. Archieve.php not loading for custom post type
  39. Submitting Custom Post Types with custom fields from Front-end form
  40. create custom meta box with default value
  41. Query Custom Post Types with checkboxes
  42. Get $post->ID from a URL
  43. WP_Query() with custom post type and taxonomy — get all terms?
  44. Displaying a div from an assigned meta_value when on a page
  45. Meta data (Tags and Categories) for Custom Posts not showing.
  46. Display different information of a custom post type
  47. show all custom posts types in home page
  48. Create Array from custom post type to display a slider
  49. Setting Post Title via Meta Data returns Auto-draft
  50. How to Echo Metadata Value in Currency Format
  51. Issue on Working with Metabox – Checkbox to enable Sale Items
  52. Filter posts by tax (dropdown) and meta value
  53. delete_post_meta() for whole CPT / multiple posts?
  54. List of child custom post types lists all custom post types
  55. How to get specific post meta by title or id
  56. Publish and save specific postmeta to a filtered post_type
  57. Query custom post type based on post id and custom field value
  58. Listing custom post types on archive page with array
  59. How to move a post to different post type with all meta data?
  60. Make (custom) post type accessible only by custom query
  61. Why do I have to press the “Update” button twice to save my meta box values?
  62. Can I query posts by taxonomy conditionally based on post type?
  63. How can I display a drop-down select of Post Names
  64. How to conditionally add Custom Post Type to Front Page
  65. how to show records that don’t have custom meta value
  66. Graphql: Unable to query (where:{author}) for custom post type
  67. WP API Response does not show my registered metadata
  68. How to detect that the save_post hook is calling the callback associated to the current edit post page only
  69. $post->post_meta not pulling any post in wordpress/php
  70. Values from meta-box not on $_POST
  71. WP_Query of custom post type sorted by meta_key has unexpected results
  72. Query not work for current taxonomy
  73. Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
  74. Custom post type suddenly stoped working after WordPress 5 update
  75. Batch Extract Date from post title and put into ACF custom field
  76. copy images from custom field to another custom field
  77. Custom Query: If One Post Object Field Value Is The Same As Another
  78. Break up posts per page in two sections
  79. Custom Post Type not showing in main loop
  80. Custom Post Type setup
  81. How to show custom field on specific custom post type posts only when filled
  82. How to handle this specific case of custom post type?
  83. new WP_query > displays posts only once instead of running through full array
  84. Pagination on search results page
  85. Querying a custom post type, but not show duplicates
  86. Save CTP post meta different values each day without overwriting previous values
  87. get_post_meta returns NULL in front-end, but correct result in back-end
  88. Shortcode to return single custom post based on post taxonomy
  89. Cannot obtain custom meta information
  90. Problem with adding custom post type meta to header by plugin
  91. How can I output WPAlchemy repeating fields meta values in my page template?
  92. Meta box data is saved but NOT displayed in the meta box text field. Why?
  93. How to call a post’s metadata in shortcode.php?
  94. Hide text if query has no posts
  95. How do I get the index for a custom post?
  96. Getting custom post types to properly display alphabetically
  97. Create query for both custom post type and category
  98. Filtering custom posts by custom fields (ACF) [closed]
  99. Save Metabox Custom Field Value
  100. Echo custom post meta from options array
Categories custom-post-types Tags custom-post-types, post-meta, query
Archive Custom Post Type
wp_get_http has been deprecated. Use WP_Http instead

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