Thursday, April 25, 2024

WordPress模板中顯示作者相關函數

這句是用來讀取WordPress後台設定的作者昵稱,

<?php the_author_nickname(); ?>

如果不願意使用昵稱而要使用名字,也可以使用其它函數:the_author顯示作者名字;the_author_login顯示作者登錄 名;the_author_url顯示作者的網站地址。

<?php the_time(’F dS, Y’); ?> 顯示發布時間

<?php the_category(’, ‘) ?> 顯示文章分類。

<?php edit_post_link(’edit’, ‘(’, ‘)’); ?>如果作者就是博客管理員,則會在登錄狀態下顯示edit編輯按鈕

the_author 顯示文章的作者

the_author_description 顯示文章作者的描述(作者個人資料中的描述)

the_author_login 顯示文章作者的登錄名

the_author_firstname 顯示文章作者的firstname(名)

the_author_lastname 顯示文章作者的lastname(姓)

the_author_nickname 顯示文章作者的昵稱

the_author_ID 顯示文章作者的ID號

the_author_email 顯示文章作者的電子郵箱

the_author_url 顯示文章作者的網站地址

the_author_link (添加於2.1版本) 顯示一個以文章作者名為鏈接名,鏈接地址為文章作者的網址的鏈接。

the_author_icq (不推薦使用) 顯示文章作者的icq

the_author_aim 顯示文章作者的aim

the_author_yim 顯示文章作者的yim

the_author_msn (不推薦使用) 顯示文章作者的msn

the_author_posts 顯示文章作者已發表文章的篇數

the_author_posts_link 顯示一個鏈接到文章作者已發表文章列表的鏈接

list_authors (不推薦使用) 顯示blog所有作者和他們的相關信息。完整函數如下:

參數:

optioncount:是否顯示各作者已發表文章的篇數,可選值為:TRUE 和 FALSE(默認值)

exclude_admin:是否不列出管理員,可選值為:TRUE(默認值) 和 FALSE

show_fullname :是否顯示各作者的全名,可選值為:TRUE 和 FALSE(默認值)

hide_empty:是否不顯示發表文章數為0的作者,可選值為:TRUE(默認值) 和 FALSE

feed:鏈接到各個作者發表文章的RSS供稿種子鏈接名,默認為空,不顯示RSS供稿種子

feed_image:供稿種子的圖片地址,如果提供此項,則覆蓋上面的feed,默認為空

例如:

代表不顯示各個作者的發布文章數,列出管理員,顯示各作者的全名,顯示發布文章數為0的作者和不顯示RSS供稿種子。

<?php list_authors(optioncount, exclude_admin, show_fullname, hide_empty, ‘feed’, ‘feed_image’); ?>

<?php list_authors(FALSE, FALSE, TRUE, FALSE); ?>

wp_list_authors 顯示blog作者列表,如果作者發表過文章,則他的名字將鏈接到他發表的文章列表中。可定義是否顯示其他信息。

參數:

optioncount:是否顯示各個作者發表文章數,可選值:true 和 false(默認值)

exclude_admin:是否不顯示“admin”用戶,可選值:true(默認值) 和 false

show_fullname:是否顯示各個作者的全名,如果不顯示,將顯示昵稱。可選值:true 和 false(默認值)

hide_empty:是否不顯示發表文章數為0的作者,可選值:true(默認值) 和 false

feed:鏈接到各個作者發表文章的RSS供稿種子鏈接名,默認為空,不顯示RSS供稿種子

feed_image:供稿種子的圖片地址,如果提供此項,則覆蓋上面的feed,默認為空

例如:

<?php wp_list_authors(’show_fullname=1&optioncount=1′); ?>

One comment

  1. 感謝博主的分享, 正好用到了!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.