Quantcast

Rewrite wordpress post template based on custom post type

Many of us find it very difficult when it comes to have custom post template. Even if you create a custom post template, the question comes how would you define for your custom post type?

I have written a quick and handy tutorial for using a custom post template based on your custom post type.

First, we will add a template redirect call in your theme’s function.php file

Now, let’s prepare our function for calling the custom template

First, we get the post_type by calling get_post() function.

Under the IF condition, we are including the actual post template file. The function get_template_directory() is a built-in WordPress function which calls the full physical path of your active theme directory and then we call the file from it.

Hope it helps

Looking for a quality hosting service? here are a few I suggest.
BlueHost | HostGator | Media Temple
Admin
Admin
Ali has been an entrepreneur in web, video and related technologies. Having worked with many business across the globe, Ali stands truly a great pillar in the business working with him.