0

I created a WordPress theme with one page design format which means I wrote all the code in the main index.php file. Now I need to make a different page with separate URL but for some reason it still displays the same content.

Basically https://mypage.com is the main page and I need to have a new separate page for some content like https://mypage.com/something but for some reason whenever I create a new page it still shows the content from the main page.

I don't know what's the WordPress way of doing things like that, should I just create a new directory with new files?

1 Answer 1

1

Because the naming convention is matter. You can create a new template for your different page and name it "page.php" and on the header portion give it a name:

<?php
/**
 * Template name: Different page tempate
 */

get_header(); ?>

<div class="yourclass">
    <!-- Your different template code should go here -->
</div>


<?php
get_footer();

Once you are done then go to Pages>Add New & on the right sidebar you will see the new template name under "Template" dropdown. Select it as your new page template and publish. enter image description here

2
  • Ohh, thank you very much sir. It's exactly what i was looking for, i had no idea about different templates before.
    – drpzxc
    Commented Mar 11, 2019 at 19:42
  • You are most welcome!
    – Shihab
    Commented Mar 11, 2019 at 19:42

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.