php调用文章至首页,[转载]wordpress首页如何调用最新文章等代码
发布日期:2022-02-18 13:19:52 浏览次数:6 分类:技术文章

本文共 1292 字,大约阅读时间需要 4 分钟。

显示最新文章<?php

query_posts('showposts=5'); ?>

?>

href="<?php the_permalink()

?>"><?php the_title();

?>

显示热评文章<?php

$result = $wpdb->get_results("SELECT

comment_count,ID,post_title FROM $wpdb->posts ORDER

BY comment_count DESC LIMIT 0 , 10");

foreach ($result as $topten) {

$postid = $topten->ID;

$title = $topten->post_title;

$commentcount = $topten->comment_count;

if ($commentcount != 0) { ?>

href="<?php echo get_permalink($postid);

?>" title="<?php echo $title

?>"><?php echo $title

?>

显示最新评论

global $wpdb;

$sql = "SELECT DISTINCT ID, post_title, post_password,

comment_ID,

comment_post_ID, comment_author, comment_date_gmt,

comment_approved,

comment_type,comment_author_url,

SUBSTRING(comment_content,1,30) AS com_excerpt

FROM $wpdb->comments

LEFT OUTER JOIN $wpdb->posts ON

($wpdb->comments.comment_post_ID =

$wpdb->posts.ID)

WHERE comment_approved = '1' AND comment_type = '' AND

post_password = ''

ORDER BY comment_date_gmt DESC

LIMIT 10";

$comments = $wpdb->get_results($sql);

$output = $pre_HTML;

$output .= "n

  • ";

foreach ($comments as $comment) {

$output .=

"n

".strip_tags($comment->comment_author)

.":" . "

";

}

$output .= "n

";

$output .= $post_HTML;

echo $output;?>

显示文章分类

Categories

?>

显示Wordpress标签云

wp_tag_cloud('smallest=8&largest=36&');

?>

显示归档

Archives

?>

在侧栏显示页面列表

Pages

?>

转载地址:https://blog.csdn.net/weixin_28926205/article/details/115879141 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:matlab最炫名族风,matlab版的《最炫民族风》
下一篇:java exception关系,Java Exception 在超类和子类间的关系

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月10日 12时23分03秒