Reputation: 3471
I have created a wordpress template that loads for this page - example.com/products The template name is page-products.php and it is located inside my theme folder. It works only for http://example.com/products, is there any way I can make it work for templates like http://example.com/products/clothing, so when a user visits this url the page will be rendered from the products template?
<?php get_header(); ?>
<!--
My Custom Products page
-->
<?php get_footer(); ?>
Upvotes: 0
Views: 98
Reputation: 61
You can create a custom page template to accomplish this. The file would be named something like template-clothing.php
. Additionally, you could put this file in a sub-folder called page-templates
if you have several page templates (this removes cluster from the root directory).
The header for your template could look like this:
<?php
/*
Template Name: Clothing
*/
?>
Once this file has been created, the template can be selected under Page Attributes
in the page editor, and the page will subsequently be displayed with this appearance.
Upvotes: 1