0

How can I show the same post content with two different post layouts on two different URLs?

For example

https://www.domain.com/help-brothers/post-layout-1/post-name
https://www.domain.com/help-brothers/post-layout-2/post-name

1 Answer 1

1

You can pass the layout name as a GET parameter and then change the design based on that. So your URL should be something like this:

http://domain.com/post-name?layout=layout-1

Now in your single.php file or whatever file that renders the template, you can do this check to show the different layouts:

<?php 
// If the header is different two, you should call for different headers too, 
// Check this for showing different headers
// https://developer.wordpress.org/reference/functions/get_header/
if( isset( $_GET['layout'] )  && $_GET['layout'] == 'layout-1' ) {
    // Show the design for for the first layout 
}
else if ( ... ) {
    // Show the design for other layouts 
} 
1
  • Thank you very much it will work
    – Mano Odin
    May 6, 2021 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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