0

So I've been wondering if there's a way to force WordPress to load the homepage template for a URL.

Eg.: https://example.com/example/another-example/my-post-slug/ should load the template belonging to https://example.com but some widgets would display different data according to the slug in the URI.

Maybe there's an action or a hook that could do this? This would be trivial to solve within an MVC framework, not so much in WP.

Any ideas?

1 Answer 1

1

You can create a custom template and assign that to both your homepage as well as that specific post. Templates are normally for the page post type, but you can add

* Template Post Type: post, page

to the comment at the top of the template file to make this available for posts as well.

You can then use Wordpress functions such as is_front_page() to check to see if you are on your homepage or just a post page - this would allow you to load different widget areas / sidebars.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.