Custom Post Type as Home Page Problem

The error is in the code you added:

function enable_front_page_stacks( $query ){
    global $post, $wp_query;
    if('' == $query->query_vars['post_type'] && 0 != $query->query_vars['page_id'])
        $query->set('post_type', 'wpwebinar');
}

Specifically $query->set(). This call will specifically set the post type to “wpwebinar” if it’s not explicitly set to anything else. As a result, just hitting a regular page will force it to assume “wpwebinar” and load the custom post type template.

Instead, change your function to this:

function enable_front_page_stacks( $query ){
    if(( ! isset($query->query_vars['post_type']) || '' == $query->query_vars['post_type']) && 0 != $query->query_vars['page_id'])
        $query->query_vars['post_type'] = array( 'page', 'wpwebinar' );
}

This was the original enable_front_page_stacks() function I wrote, but using “wpwebinar” instead of “stack” as the additional custom post type.


Referencing a Template File from a Plugin

Usually, the best guidelines I can give include registering a CPT with a plugin and leaving the CPT templates up to the theme. This typically works better with styling and allows the end user complete control over the site design. However, there are rare situations were it makes sense to specify the CPT template in the plugin itself.

To take care of this, you need to hook in to the get_single_template() function in core to tell it where to get the file. Here’s the typical request pattern:

template-loader.php
--> if ( is_single() ) $template = get_single_template()

-- --> template.php -> get_single_template()
-- -- --> $templates[] = array( 'single.php', 'single-{post_type}.php' );
-- -- --> return get_query_template( 'single', $templates )

-- -- -- --> template.php -> get_query_template( $type, $templates )
-- -- -- -- --> if ( empty($templates) ) $templates = array( '{$type}.php' );
-- -- -- -- --> return apply_filters( "{$type}_template", locate_template( $templates ) )

In order to register your plugin-hosted CPT template, you need to hook on to this filter and specify its location.

function load_plugin_cpt_template( $path ) {
    $path = dirname(__FILE__) . '/single-wpwebinar.php';

    return $path;
}
add_filter( 'wpwebinar_template', 'load_plugin_cpt_template' );

I use dirname( __FILE__ ) above based on the assumption that your CPT template is at the same level as the file with this function. If not, adjust the include path accordingly. Note that this function will absolutely override any single-wpwebinar.php specified by the theme.

As a safeguard, you can check the passed-in value of $path to see if we’re using single.php or a theme-specified override, but that’s an exercise I leave to you.

There is also a more complete tutorial posted on my site: http://jumping-duck.com/tutorial/theme-ready-custom-post-types-in-wordpress/.