Home > CMS Tutorial > WordPress > The whole process of WordPress theme production (11): making page.php

The whole process of WordPress theme production (11): making page.php

藏色散人
Release: 2023-02-21 10:16:21
forward
1569 people have browsed it

I introduced you to "The whole process of WordPress theme production (10): Making comments.php". This article continues to introduce to you how to make page.php. Let's take a look together~

The whole process of WordPress theme production (11): making page.php

page.php is also a page. Maybe you don’t understand what a page means. Aren’t all web pages on a blog a page? The page we are referring to here is a separate page, such as "About", "Contact Information", etc., which can be added and modified in the WordPress backend - Page.

There are many things in this page.php that are similar to single.php, or basically the same. We don’t do too much analysis on some of the content here, and just go to the results. If you don’t understand anything, You can read the whole process of WordPress theme production (8): Creating index.php.

1. Add title

Search code: <!-- Column 1 / Content -->

Change to:

<!-- Column 1 / Content -->
<h2 class="grid_12 caption clearfix"><?php the_title(); ?></h2>
Copy after login

2. Add page content

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vel porta erat. Quisque sit amet risus at odio pellentesque sollicitudin. Proin suscipit molestie facilisis. Aenean vel massa magna. Proin nec lacinia augue. Mauris venenatis libero nec odio viverra consequat. In hac habitasse platea dictumst.</p>
Copy after login

Change to:

<?php the_content(); ?>
Copy after login

3. Add a comment box

Change the space between and Delete all code (including )

and replace it with:

<?php comments_template(); ?>
Copy after login

4. Add query statement

Search code: <!-- Column 1 / Content -->

Change to:

<!-- Column 1 / Content -->
<?php if (have_posts()) : the_post(); update_post_caches($posts); ?>
Copy after login

Search:

</div>
<?php get_sidebar(); ?>
Copy after login

Change to:

</div>
<?php else : ?>
<div class="grid_8">
Copy after login

The page you wanted was not found!

</div>
<?php endif; ?>
<?php get_sidebar(); ?>
Copy after login

Our page.php is finished. There are also two pages, the sidebar page full_width.php and the contact page contact.php. The production methods are exactly the same, so I won’t go into details here. I have already written them directly and you can download them. You may ask, how to use these two pages? I wrote two notes in front of these two pages respectively:

<?php
/*
Template Name: Page without sidebar
*/
?>
<?php
/*
Template Name: contract
*/
?>
Copy after login

When you create a new page in the WordPress backend in the future, you can select the page template in the right column. You can select Page without sidebar or contract. Leave it unchecked. The page.php template is used by default! You can just change the content of the contact information in the sidebar of contact.php.

So far, our series of tutorials on WordPress theme production has come to an end. To be honest, you probably didn’t learn anything. What I taught was really bad. Just treat it as a perceptual understanding process of WordPress theme production. Bar. Finally, we provide the download of the theme we have created. It is estimated that no one will be willing to use such a theme, it is too ugly! Also, there is no paging function for comments.

Recommended learning: "WordPress Tutorial"

The above is the detailed content of The whole process of WordPress theme production (11): making page.php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:ludou.org
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template