0
votes

This is my code to generate the custom post type.

add_action( 'init', 'feature_post_type' );

function feature_post_type() {

    $labels = array(
                'name'               => 'Feature Posts',
                'single_name'        => 'Feature Post',
                'add_new'            => 'Add New',
                'add_new_item'       => 'Add New Feature Post',
                'edit'               => 'Edit',
                'edit_item'          => 'Edit Feature Post',
                'new_item'           => 'New Feature Post',
                'view'               => 'View',
                'view_item'          => 'View Feature Post',
                'search_items'       => 'Search Feature Posts',
                'not_found'          => 'No Features found',
                'not_found_in_trash' => 'No Features found in Trash',
                );

    $args = array(
                'labels'                => $labels,
                'public'                => true,
                'rewrite'               => array('slug' => 'feature'),
                'menu_postion'          => 5,
                'has_archive'           => true,
                'hierarchical'          => true,
                'taxonomies'            => array('category', 'post_tag'),
                'can_export'            => true,
                'supports'              => array( 'title', 'author', 'editor', 'comments', 'thumbnail', 'custom-fields', 'excerpt')
        );

register_post_type( 'feature_posts ', $args );

}

The admin screen for the post type though lists all the posts from the wordpress database, while it should only display the feature_posts entries. You can see a screenshot of what I mean here. None of those posts are actually Feature_Posts, yet are still appearing in the custom post type admin screen.

I've gone through the codex page for custom post types and there doesn't seem to be anything pertaining to my problem.

Am I missing something from my $args array that limits the kind of posts the admin screen will display?

1
Sounds to me like something is hooking into pre_get_posts() somewhere in your code and it's altering the post query. Is that a possibility? - Ohgodwhy
Although it doesn't answer your question, you know there's already a "featured" style post (called "sticky" posts) right? - naththedeveloper
@ɴᴀᴛʜ I didn't consider sticky posts because I don't want to these stick to the top of the homepage/category pages. - colinxr

1 Answers

0
votes

use below query in sql.

DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='custom-fields');

DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'custom-fields');
DELETE FROM wp_posts WHERE post_type = 'custom-fields';