Support » Fixing WordPress » {$type}_template filter

  • Hi!

    I’ve defined a custom post type called movie in a plugin and want to include its templates in the plugin folder so that people can use it without touching their theme folder.

    I’ve seen that one can use a filter named {$type}_template to be able to locate and load custom templates for specific types, but I can’t seem to get it to work. This is a summary of the code I’m using:

    $args = array(
    'show_ui' => true,
    'public' => true,
    'supports' => array('title', 'editor', 'thumbnail'),
    'has_archive' => 'movies'
    register_post_type('movie', $args);
    function my_movie_template($template) {
    $template = plugin_dir_path(__FILE__) . '/templates/single-movie.php';
    return $template;
    add_filter('movie_template', 'my_movie_template') ;

    Any help would be appreciated.

  • The topic ‘{$type}_template filter’ is closed to new replies.