wordpress 常用函式

2022-03-11 16:43:52 字數 1114 閱讀 3953

wp_loginout():主題中顯示「登出」鏈結。

wpautop() :這個函式用來轉換換行符字串為

標記,並把雙換行符作為乙個新的段落的開始,在前一段加入

,並在新的段落加上

<?php get_archives('postbypost', 10); ?>

<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>
隨機文章

<?php 

$rand_posts = get_posts('numberposts=10&orderby=rand');

foreach( $rand_posts as $post ) :

?>

"><?php the_title(); ?>

<?php endforeach; ?

<?php 

global $wpdb;

$sql = "select distinct id, post_title, post_password, comment_id,

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)

post_password = ''

order by comment_date_gmt desc

limit 10";

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

$output = $pre_html;

foreach ($comments as $comment)

$output .= $post_html;

echo $output;?>

wordpress 常用函式

wp loginout 主題中顯示 登出 鏈結。wpautop 這個函式用來轉換換行符字串為 標記,並把雙換行符作為乙個新的段落的開始,在前一段加入 並在新的段落加上 或 隨機文章 rand posts get posts numberposts 10 orderby rand foreach ra...

WordPress常用函式大全

判斷頁面函式 is home 是否為主頁 is single 是否為內容頁 post is page 是否為內容頁 page is category 是否為category archive頁 is tag 是否為tag存檔頁 is date 是否為指定日期存檔頁 is year 是否為指定年份存檔頁...

整理WordPress常用模板函式

對於很多wordpress新手來說,不懂任何 的情況下去瞎改wordpress主題,得出的效果往往會出現語法錯誤之類的東西或效果不盡人意。想要修改 wordpress主題模板檔案最基本的當然要懂得html 熟悉div css布局,php 也得略懂一二。不過一些比較簡單易懂的 和函式,學習起來並不難,...