Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress, alternative single post template

Tags:

wordpress

For a project of mine I need to define an alternative template for single posts. To be more specific I need each post to be displayed as usual when the website is browsed but I need to create different single pages reachable from different URL to create a sort of a mini-website for each post.

(I'm actually using the WooCommerce plugin and what I need to do is to create a mini-website for each product. This needs to be something "outside" from the main website, with a complete different graphic template and is going to be reachable through a QR-code).

Hope it makes a bit of sense. Thanks for your advices and/or suggestions. Angelo

like image 457
Angelo Avatar asked Nov 14 '22 08:11

Angelo


1 Answers

I think the easiest way to do that is by registering a custom post type for the special posts that get this special "single.php" template. Then, you can simply write a new single template titled post-[custom post_type].php. Any post you register of this type will use that template.

OR... If you don't actually need them to be posts, it's even easier if you publish them as pages. By default, pages let you assign a specific page template in the edit screen. So you could make any number of custom templates. Just make sure you add the special header:

/* Template Name: Custom Page */

...so WP knows it's a page template.

like image 74
emersonthis Avatar answered May 28 '23 15:05

emersonthis