theme development - Displaying the right content on a page url

admin2025-06-02  2

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 is the main page and I need to have a new separate page for some content like 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?

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 is the main page and I need to have a new separate page for some content like https://mypage/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?

Share Improve this question edited Mar 11, 2019 at 19:55 butlerblog 5,1413 gold badges28 silver badges44 bronze badges asked Mar 11, 2019 at 19:22 drpzxcdrpzxc 33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748817916a313975.html

最新回复(0)