wordpress 内置了许多的常用函数,以方便我们在需要显示内容的地方进行直接调用,这些函数都是直接封装好的,也就是利用了mvc的模式,比如调用标题 tle_title(),还有许多像这样的函数,在需要的地方直接放置函数即可,很是方便,下面夏日博客把收集来的常用的代码分享下,以方便在制作模板时进行直接的调用,说明一点,这些函数都是 wordpress 里面内置的,可能样式跟你的网站不太协调,这些样式代码我们也可以在函数里面进行DIY,或者更改CSS样式,好了,不多说了,下面是这些常用的函数。,显示最近文章,显示分类:Categories ,显示存档,显示标签云,显示友情链接:< ?php wp_list_bookmarks('title_li=&categorize=0'); ?>,显示标签,显示页面导航菜单:< ?php wp_list_pages('title_li='); ?>,显示最新评论:,< ?php
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,";
}
$output .= "\n,";
foreach ($comments as $comment) {
$output .= "\n
".strip_tags($comment->comment_author)
.":" . "ID) .
"#comment-" . $comment->comment_ID . "\" title=\"on " .
$comment->post_title . "\">" . strip_tags($comment->com_excerpt)
."
";
$output .= $post_HTML;
echo $output;?>,显示热门评论:,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) { ?>,title="< ?php echo $title ?>">< ?php echo $title
?>,< ?php } } ?>,如果模板是自己写的,需要自己 DIY CSS样式。,

wordpress 内置了许多的常用函数,以方便我们在需要显示内容的地方进行直接调用,这些函数都是直接封装好的,也就是利用了mvc的模式,比如调用标题 tle_title(),还有许多像这样的函数,在需要的地方直接放置函数即可,很是方便,下面夏日博客把收集来的常用的代码分享下,以方便在制作模板时进行直接的调用,说明一点,这些函数都是 wordpress 里面内置的,可能样式跟你的网站不太协调,这些样式代码我们也可以在函数里面进行DIY,或者更改CSS样式,好了,不多说了,下面是这些常用的函数。

显示最近文章

显示分类:Categories

显示存档

显示标签云

显示友情链接:< ?php wp_list_bookmarks('title_li=&categorize=0'); ?>

显示标签

显示页面导航菜单:< ?php wp_list_pages('title_li='); ?>

显示最新评论:

< ?php
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

";
}
$output .= "\n

";
foreach ($comments as $comment) {
$output .= "\n
".strip_tags($comment->comment_author)
.":" . "ID) .
"#comment-" . $comment->comment_ID . "\" title=\"on " .
$comment->post_title . "\">" . strip_tags($comment->com_excerpt)
."
";
$output .= $post_HTML;
echo $output;?>

显示热门评论:

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) { ?>

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

< ?php } } ?>

如果模板是自己写的,需要自己 DIY CSS样式。

,

wordpress 内置了许多的常用函数,以方便我们在需要显示内容的地方进行直接调用,这些函数都是直接封装好的,也就是利用了mvc的模式,比如调用标题 tle_title(),还有许多像这样的函数,在需要的地方直接放置函数即可,很是方便,下面夏日博客把收集来的常用的代码分享下,以方便在制作模板时进行直接的调用,说明一点,这些函数都是 wordpress 里面内置的,可能样式跟你的网站不太协调,这些样式代码我们也可以在函数里面进行DIY,或者更改CSS样式,好了,不多说了,下面是这些常用的函数。

显示最近文章

显示分类:Categories

显示存档

显示标签云

显示友情链接:< ?php wp_list_bookmarks('title_li=&categorize=0'); ?>

显示标签

显示页面导航菜单:< ?php wp_list_pages('title_li='); ?>

显示最新评论:

< ?php
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

";
}
$output .= "\n

";
foreach ($comments as $comment) {
$output .= "\n
".strip_tags($comment->comment_author)
.":" . "ID) .
"#comment-" . $comment->comment_ID . "\" title=\"on " .
$comment->post_title . "\">" . strip_tags($comment->com_excerpt)
."
";
$output .= $post_HTML;
echo $output;?>

显示热门评论:

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) { ?>

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

< ?php } } ?>

如果模板是自己写的,需要自己 DIY CSS样式。

最后修改:2025 年 09 月 10 日
如果觉得我的文章对你有用,请随意夸赞