WordPress

WordPress 是一个用PHP开发的博客平台,它不是一个框架,但如果拆分一下代码,可能可以充当一个不错的框架

<!-- 评论模板:显示指定id的评论-->
<div>
<ol class="commentlist">
<?php
//Gather comments for a specific page/post 收集特定页面/博文的评论
$comments = get_comments(array(
'post_id' => 1, // XXX处必填,设置要显示哪条评论id号
'status' => 'approve' //Change this to the type of comments to be displayed 将其更改为要显示的注释类型
));
//Display the list of comments 显示评论列表
wp_list_comments(array(
'per_page' => 10, //Allow comment pagination 允许评论分页
'reply_text' => null, // 回复按钮显示内容 设置null去掉回复按钮
'reverse_top_level' => false //Show the oldest comments at the top of the list 在列表顶部显示最早的评论
), $comments);
?>
</ol>
</div>

<!-- 文章分类显示模板-->
<article class="article">
<section class="left">
<?php
$cats = get_categories();
foreach ($cats as $cat) {
query_posts('showposts=10&cat=' . $cat->cat_ID);
?>
<h3><?php echo $cat->cat_name; ?></h3>
<ul class="sitemap-list">
<?php while (have_posts()) {
the_post(); ?>
<li><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></li>
<?php }
wp_reset_query(); ?>
</ul>
<?php } ?>
</section>
</article>
<hr>
<section>
<?php
query_posts('showposts=10&cat=1');
while (have_posts()):the_post();
?>
<li><a href="<?php the_permalink(); ?>" title="
<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</section>
<hr>
<div>
<?php query_posts('showposts=10&cat=1');
while (have_posts()):the_post(); ?>
<li><a href="<?php the_title(); ?> "><?php the_title(); ?></a></li>
<?php endwhile; ?>
</div>

<!-- 完整文章模板 -->
<div>
<div class="wrap">
<?php if (is_home() && !is_front_page()) : ?>
<header class="page-header">
<h1 class="page-title"><?php // single_post_title(); ?></h1>
</header>
<?php else : ?>
<header class="page-header">
<h2 class="page-title"><?php _e('Posts', 'twentyseventeen'); ?></h2>
</header>
<?php endif; ?>
</div>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
if (have_posts()) :
/* Start the Loop */
while (have_posts()) : the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part('template-parts/post/content', get_post_format());

endwhile;

the_posts_pagination(array(
'prev_text' => twentyseventeen_get_svg(array('icon' => 'arrow-left')) . '<span class="screen-reader-text">' . __('Previous page', 'twentyseventeen') . '</span>',
'next_text' => '<span class="screen-reader-text">' . __('Next page', 'twentyseventeen') . '</span>' . twentyseventeen_get_svg(array('icon' => 'arrow-right')),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'twentyseventeen') . ' </span>',
));

else :

get_template_part('template-parts/post/content', 'none');

endif;
?>
</main><!-- #main -->
</div><!-- #primary-->
</div><!-- .wrap -->

<!--评论模板-->
<div>
<?php
/**
* The template for displaying comments
*
* This is the template that displays the area of the page that contains both the current comments
* and the comment form.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since 1.0
* @version 1.0
*/
/*
* If the current post is protected by a password and
* the visitor has not yet entered the password we will
* return early without loading the comments.
*/
if (post_password_required()) {
return;
}
?>
<div id="comments" class="comments-area">

<?php
// You can start editing here -- including this comment!
if (have_comments()) :
?>
<h2 class="comments-title">
<?php
$comments_number = get_comments_number();
if ('1' === $comments_number) {
/* translators: %s: post title */
printf(_x('One Reply to &ldquo;%s&rdquo;', 'comments title', 'twentyseventeen'), get_the_title());
} else {
printf(
/* translators: 1: number of comments, 2: post title */
_nx(
'%1$s Reply to &ldquo;%2$s&rdquo;',
'%1$s Replies to &ldquo;%2$s&rdquo;',
$comments_number,
'comments title',
'twentyseventeen'
),
number_format_i18n($comments_number),
get_the_title()
);
}
?>
</h2>

<ol class="comment-list">
<?php
wp_list_comments(
array(
'avatar_size' => 100,
'style' => 'ol',
'short_ping' => true,
'reply_text' => twentyseventeen_get_svg(array('icon' => 'mail-reply')) . __('Reply', 'twentyseventeen'),
)
);
?>
</ol>

<?php
the_comments_pagination(
array(
'prev_text' => twentyseventeen_get_svg(array('icon' => 'arrow-left')) . '<span class="screen-reader-text">' . __('Previous', 'twentyseventeen') . '</span>',
'next_text' => '<span class="screen-reader-text">' . __('Next', 'twentyseventeen') . '</span>' . twentyseventeen_get_svg(array('icon' => 'arrow-right')),
)
);

endif; // Check for have_comments().

// If comments are closed and there are comments, let's leave a little note, shall we?
if (!comments_open() && get_comments_number() && post_type_supports(get_post_type(), 'comments')) :
?>

<p class="no-comments"><?php _e('Comments are closed.', 'twentyseventeen'); ?></p>
<?php
endif;

comment_form();
?>

</div><!-- #comments -->
</div>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值