Custom Post Type Dashboard Tab not displaying any posts
I created a custom post:
/*= Add Custom Post Type: Board Members
/****************************************************/
add_action( 'init', 'create_board_posttype' );
function create_board_posttype() {
register_post_type( 'board',
array(
'labels' = array(
'name' = __( 'Board Members' ),
'singular_name' = __( 'Board Member' ),
'add_new_item' = __( 'Add New Board Member' ),
'edit_item' = __( 'Edit Board Member' ),
'new_item' = __( 'New Board Member' ),
'view_item' = __( 'View Board Member' ),
'search_items' = __( 'Search Board Members' ),
'not_found' = __( 'No Board Members Found' ),
'archives' = __( 'Board Members Archives' ),
'insert_into_item' = __( 'Insert into Board Member' ),
),
'public' = true,
'supports' = array( 'title', 'editor', 'custom-fields', 'thumbnail', 'page-attributes' ),
'has_archive' = true,
'rewrite' = array('slug' = 'board'),
)
);
}
I then went and added 10 posts successfully and they are displaying on the frontend fine.
Fast forward 4 weeks and I went in to edit a post but I am seeing No board members found.
It shows that there are 10 Board Members published by actually displays none in the list:
All (10) | Published (10)
No Board Members Found
Clearly WP knows there are board members (All (10)) but it wont show them... I don't know where to start?
Ok, I found the issue but I don't understand why.
I have another custom_post_type: jobs
On the frontend I try to filter jobs within last x days. When I remove this code, the Board Members re-appear:
add_action( 'pre_get_posts', 'custom_query_vars' );
function custom_query_vars( $query ) {
if ( $query-is_main_query() )
{
if ( is_archive('job') )
{
$days = get_field('job_expiry_days', 'option');
$query-set( 'date_query', array(
'column' = 'post_date',
'after' = '- '.$days.' days'
) );
}
}
return $query;
}
Topic functions init custom-post-types Wordpress
Category Web