$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>theme development - Displaying the right content on a page url|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

theme development - Displaying the right content on a page url

matteradmin12PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far