• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

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.

Reader Interactions

Comments

  1. Alexander Khmelnitskiy says

    March 13, 2018 at 5:38 am

    wp_reset_postdata(); – this statment is unreaceble.

    Log in to Reply
    • Brad Dalton says

      March 13, 2018 at 5:41 am

      Thanks, updated both Gists. Much appreciated!

      Log in to Reply
  2. james says

    February 22, 2018 at 11:04 am

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

    Log in to Reply
    • Brad Dalton says

      February 22, 2018 at 11:06 am

      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.

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags