<?php
/*
Plugin Name: CPT Without Slug
Description: A test plugin to register a CPT without slug
Author: David MÃ¥rtensson
Version: 0.0.4
Author URI: http://feedmeastraycat.net/
*/

add_action( 'init', 'mycpt_init' );
function mycpt_init() {
  register_post_type( 'mycpt', array(
    'public' => true,
    'rewrite' => array( 'with_front' => false, 'slug' => '/' )
  ) );
}
 
add_action( 'mycpt_rewrite_rules', 'mycpt_remove_rewrite_rules', 10, 1 );
function mycpt_remove_rewrite_rules( $default_rules ) {
  return array();
}
 
add_action( 'pre_get_posts', 'mycpt_pre_get_posts', 11, 1 ); // Should prob run last
function mycpt_pre_get_posts( &$wp_query ) {
  if ( !is_admin() && isset($wp_query->query_vars['name']) && !empty($wp_query->query_vars['name']) ) {
    $wp_query->set( 'post_type', array( 'post', 'mycpt' ) );
  }
}