WordPress.org

Ready to get started?Download WordPress

Forums

{$type}_template filter (1 post)

  1. leemon
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic