php调用文章至首页,[转载]wordpress首页如何调用最新文章等代码

显示最新文章<?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)

.":" . "

get_permalink($comment->ID) .

"#comment-" . $comment->comment_ID . "" title="on

" .

$comment->post_title . "">" .

strip_tags($comment->com_excerpt)

."

";

}

$output .= "n

";

$output .= $post_HTML;

echo $output;?>

显示文章分类

Categories

?>

显示Wordpress标签云

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

?>

显示归档

Archives

?>

在侧栏显示页面列表

Pages

?>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值