pre_get_posts
doesn’t just run on the frontend, it runs on all post queries, and that includes RSS feeds, XMLRPC, AJAX, REST API, and WP Admin.
You need to check in your pre_get_posts
filter and exit early so that it only applies to the places you want it to apply to.
e.g.
if ( is_admin() ) {
return;
}
Additionally, this code is incorrect:
if ( is_archive('job') )
This checks if the main query is a job archive, but it should be checking if $query
is a job archive, so it needs to be $query->is_archive( 'job' )
.
This is also followed by another bug:
$days = get_field('job_expiry_days', 'option');
If job_expiry_days
is not set, then it will be a falsey value, resolving to 0
, meaning only posts older than 0 days ago will be found, aka nothing.
Related Posts:
- How come Featured Image isn’t showing up in my Custom Post Type?
- How to use a custom post type archive as front page?
- Set posts of a custom post type to be private by default?
- Custom post status not working
- clients list using wordpress
- Find callback function for custom taxonomy metabox
- Date archives for custom post type
- How can I add dropdown widget/box to admin post page?
- Using Default WordPress Custom Header Image Crop Feature in a Post Type / MetaBox
- How do I add a custom post type to the Featured Content in twenty fourteen theme?
- Limiting number of custom posts shown on taxonomy page
- Custom post type loops with different page templates
- Append taxonomy terms as class names in markup?
- Display only custom post type count for current author on the “At a Glance” dashboard widget
- Loop through posts of a custom-post-type (event) and create .ics (iCal) file?
- How To Enable Block Editor (Gutenberg) for Existing Post Type via functions.php
- GravityForm: Populate Dropdown with custom post type [closed]
- How to retrieve category NAME instead of ID in a function with a taxonomy custom field?
- Create a post in custom post type using field in registration form after users submit form
- right_now_content_table_end function not working?
- WooCommerce product search titles only
- Notice: Undefined index: suppress_filters
- Custom Taxonomy Permalinks Redirection
- Add custom column in custom post type edit page
- I did group my search results by post type, but how can i give each of them its own order?
- custom post type not showing in menu
- Change custom post type slug from plugin options
- Change CPT archive title
- I need to add endpoint for wordpress categories
- Featured image overlay when changing post status
- ACF field key/value to show on taxonomy list
- Re-registering a custom post type not working (not showing up)
- Query taxonomy of taxonomy of custom post type
- Hide a widget inside a div on specific type of post
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- How to change permalink to include custom post type
- Add term to custom post type on draft
- Global custom meta box
- Template not working for the custom Post type
- Warning: Invalid argument supplied for foreach() [closed]
- Custom post type isn’t working
- PHP question: how to combine syntax?
- How to hook WP initialization without modifying functions.php
- Loop increase number
- custom post for slider
- Navigate posts with different post type that are in the same categories
- Show Custom Message in WordPress Admin
- How exclude or skip post type with get_next_post_link
- Prevent A Specific Custom Post Type Showing In WP Search Results Page
- Create short URL with auto 301 redirect
- Is it possible to use array_walk() to append terms to an array of posts?
- WordPress notification if new post published
- Get current user id
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- Custom posts – tag pagination
- Adding custom post formatting options in custom post types
- Twitter Product Cards
- Custom meta box in custom post type not working
- Excerpt length: get first paragraph
- Function to add custom HTML into head in custom post-type list page
- Submit Custom Postypes from frontend
- Need help with Custom Post Types and Taxonomies
- Conflict in function to allow single post template based on category
- new post-type how do i retain the plugins on my sidebar?
- set object terms after some some time of published post – functions.php
- update custom taxonomy custom fields
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- Pagination not working in custom post type. Help
- How to add specific terms in a custom post type?
- how to display author name in custom post type
- Store a value in global scope after init hook is fired
- Limit custom post type to the authors only on front-end!
- Urgent – WordPress keeps creating posts
- Create posts inside CPT post
- ACF field check value of field on all other articles
- Problem with multi checkboxes value in metabox?
- Create dynamic logo carousel without using any plugin
- Send mail to author when custom post type is saved
- Recovering data about custom post and taxonomy types
- wordpress does not see the correct custom taxonomy hierarchy
- is using “require_once” in wordpress theme affect the speed ???
- Custom permalink rewrite rules – how do I fix this?
- Populate custom post type/custom fields from an external database
- How to sort custom post’s category by id from the theme’s function.php?
- Work and Display a Custom Post Type as a normal Post
- Custom Field to post_title
- Post Custom & Taxonomy 404 error
- How To Display Category list from Portfolio post type plugin?
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- call_user_func_array() error after moving to another server
- WP_Query function for custom post type
- Modify shortcode to work with custom taxonomies and slugs
- Calling the first & last post by category in custom post type
- Query custom post type and showing its content
- Allow authors to create article image
- Code in custom widget queries all posts, when it should only query the current post
- Comments are not working on Custom Post Type
- How to make a non-public post on wordpress approval?
- add_rewrite_rule not working with custom post type
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs