wordpress单篇文章模板代码
时间 : 2024-03-31 23:39:03声明: : 文章内容来自网络,不保证准确性,请自行甄别信息有效性

最佳答案
```php
<?php
/*
Template Name: Custom Single Post Template
*/
?>
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php
// Display post meta information like author, date, categories, tags, etc.
if ( is_single() ) {
twentynineteen_posted_on();
}
?>
</footer><!-- .entry-footer -->
</article><!-- #post-<?php the_ID(); ?> -->
<?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();
}
?>
<?php endwhile; // End of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
上面是一个基本的自定义单篇文章模板的代码示例。你可以将上面的代码复制粘贴到 WordPress 主题文件夹下新建的文件中,然后在后台编辑文章时选择这个模板即可。请根据需要进行修改和定制。
其他答案
```php
<?php
/*
Template Name: Custom Single Post Template
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php
wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'theme_name' ),
'after' => '</div>',
) );
?>
</footer><!-- .entry-footer -->
</article><!-- #post-## -->
<?php endwhile; // End of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
?>
这段代码是一个自定义的单篇文章模板代码,将其复制粘贴到你的WordPress主题文件中,然后在创建文章时选择这个模板即可。
上一篇
宝塔面板美化模板
https/SSL证书广告优选IDC>>
推荐主题模板更多>>
推荐文章