首页 问答 正文

WordPress如何管理页面?

注册会员 / 悠然自学 / 2023-06-11/ 浏览 159 次

WordPress可以通过页面管理器来管理页面。在WordPress后台,依次点击“页面”->“全部页面”,即可进入页面管理器。在页面管理器中,可以查看、编辑、删除页面。

例如,要创建一个新页面,可以点击页面管理器上的“新建”按钮,在打开的页面编辑窗口中输入页面标题和内容,然后点击“发布”按钮即可。以下是创建一个新页面的示例代码:

<?php
/**
 * Template Name: My Custom Page
 */
get_header(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

        <?php while ( have_posts() ) : the_post(); ?>

            <?php get_template_part( 'template-parts/content', 'page' ); ?>

            <?php
                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) :
                    comments_template();
                endif;
            ?>

        <?php endwhile; // End of the loop. ?>

    </main><!-- #main -->
</div><!-- #primary -->

<?php
get_sidebar();
get_footer(); 

上述示例代码创建了一个名为“My Custom Page”的页面模板,并包括了页面的HTML结构和WordPress循环以显示页面内容。示例代码中还包括了侧边栏和页脚等其他元素。

大家谈论
    我的见解