简体   繁体   中英

How to have a folder structure in a wordpress template (For ex : http://www.example.com/products/story)

I am new to wordpress and trying to get my head around it. I figured that I can create a custom php file as

<?php
/*
Template Name: The Story
*/
?>
<?php get_header() ?>
<?php get_sidebar(); ?>
    <div class="story_content"><?php echo get_option('story-content') ?></div>
<?php get_footer() ?>

and in the admin panel , I can add a new page and choose "the story" as the template , which will in turn , give me an URL as http://www.example.com/thestory

But for the life of me , I can't figure out how to have a directory structure in the website such as http://www.example.com/products/thestory

Can someone help me out here.

Thanks already!

You can achieve this with "Pretty Permalinks" enabled in WordPress, by simply creating two pages:

  1. A Products page with a slug of /products
  2. A The Story page that is a child of Products (ie The Story has a parent post: Products ). You'd make this slug /thestory (it will automatically be appended to the parent slug: /products )

This can all be done from within the Dashboard Pages area, without editing templates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM