首页 问答 正文

如何创建WordPress文章?

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

  1. 登录WordPress账户。
  2. 在仪表板中,点击“文章”>“添加新文章”。
  3. 在“标题”栏内输入文章标题。
  4. 在正文栏内输入文章内容,可以插入图片、视频、超链接等。
  5. 在右侧“分类目录”中选择文章所属的分类。
  6. 在右侧“标签”中添加文章的标签,以便于分类和搜索。
  7. 点击“发布”按钮,即可发布文章。

示例代码:

<?php
/*
Template Name: Custom Page Template
*/
?>

<?php 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_footer(); ?> 

以上示例代码是关于如何创建自定义页面模板的,需要添加至主题文件夹中的page-templates文件夹中。

大家谈论
    我的见解