wordpress单篇文章模板代码
时间 : 2024-03-31 23:39:03声明: : 文章内容来自网络,不保证准确性,请自行甄别信息有效性
演示地址:http://xin.zutian.com/
CMS版本:最低V 5.21
主题价格:1599.00元
发布日期:2023-12-13 23:46:41
下载安装:进入下载
下载次数:267 次
授权方式:顶级域名授权,无限开二级域名
说明: 1、可以更换域名, 一年不超过两次。
    2、模板包含整站源码,使用者不得建立非法网站。
    3、客服在线解答问题,永久免费更新升级。
    4、系统源码永久开源,模板永久开源,方便自定义修改。

最佳答案

```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主题文件中,然后在创建文章时选择这个模板即可。