In a wordpress website I have this page structure:
/posts
/another-page/posts
Basically they are two different pages listing different posts, even though the name (posts) is the same. The two pages should use different templates. For the first "posts" page I just create a file called page-posts.php, and it's automatically chosen. How can make the same thing for the other "posts" page?
Is the only solution to create a template and manually select it from the dropdown in the admin page? Isn't there any way to change the slug withouth affecting the url?
You can create two template files name page-{id}.php for each page. This would handle both pages for you.
Template Hierarchy Page Section
The IDs for each page will be unique. So when you select Edit from the WP-Admin area, look at the URL and you can find the ID.
/wp-admin/post.php?post=6163&action=edit
For this page, my page ID would 6163. So the template name would page-6163.php.
Cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With