WP SITES

2950 Tutorials & 191 Plugins

Load Single Template From Plugin For Different Post Types

This code enables you to use the single_template filter in a custom function from your plugins functions file to change the template used in your parent or child theme.

Single Custom Post Type Template

This PHP code enables you to load a template for your custom post type from a plugin.

Single Post Type Template

This code enables you to load a template for your all single posts from a plugin.

Both snippets assume your template is located in your plugins root directory and the code has been added to your plugins functions.php file.

There are various other methods you can use to load templates from your plugins folder.

4 responses to “Load Single Template From Plugin For Different Post Types”

  1. Alexander Khmelnitskiy Avatar
    Alexander Khmelnitskiy

    wp_reset_postdata(); – this statment is unreaceble.

    1. Thanks, updated both Gists. Much appreciated!

  2. Is there a way to convert this to use with other templates such as category, custom post type category, archive and authors

    1. Yes however support for this is only provided to registered users. You may find other templates on this site which do exactly what you want or request a tutorial.

Was This Tutorial Helpful?