1

I am fairly new to Wordpress (but been on the PHP circuit for a minute) and developing a plugin. I have created a custom post type with the following:

function create_post_type() {
      $result = register_post_type( 'wcdoe_summary',
        array(
          'labels' => array(
            'name' => __('Woocommerce Order Summaries'),
            'singular_name' => __( 'Woocommerce Order Summary' )
          ),
          'public'              => true,
          'publicly_queryable'  => false,
          'show_ui'             => true,
          'show_in_menu'        => true,
          'show_in_admin_bar'   => false,
          'capability_type'     => 'post',
          'has_archive'         => true,
          'hierarchical'        => false,
          'menu_position'       => null,
          'exclude_from_search' => true,
          'query_var'           => 'wcdoe_summary'
        )
      );
}
add_action( 'init', 'create_post_type' );

I am able to add posts of this type, but when I go to the Admin page to view the posts, I see "All (48) Mine (19) No posts found".

I have tried this: Custom Taxonomy with Custom Post Type Finds No Posts and saving my permalinks page to no avail. I do not currently have a taxonomy tied to this post type, but I tried that as well.

Am I misunderstanding what the show_ui setting does? Do I need to set the logic somewhere for the posts to display?

Any advice would be greatly appreciated!

3
  • is this hooked to run on the init action? everything otherwise looks ok.
    – Milo
    May 12, 2016 at 4:35
  • Hi Milo! Yes it is. I updated the code above to include the entire function with the add_action call.
    – tjfo
    May 12, 2016 at 13:47
  • A copy/paste of your code works for me, verify that there isn't something in a plugin or theme altering those queries by disabling plugins and switching to a core-bundled theme.
    – Milo
    May 12, 2016 at 15:08

1 Answer 1

1

Well just in case anyone else has this issue, my problem was that I was adding a post status of 'published' when I inserted the custom post type, rather than 'publish'. Hand meet forehead.

2
  • 1
    Yeah. It's odd that the status is not in the past tense. If you are using wp_query publish is the default status so you don't have to add it to the area array.
    – gdaniel
    May 13, 2016 at 13:28
  • Saved my life. I made the same mistake. Apr 8, 2019 at 1:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.