wordpress二次開發隨筆-2

調用分類,標籤,友情連接,搜索框


 

調用分類
get_the_category()
調用標籤
get_the_tags()
調用友情連接
wp_list_bookmarks()
調用指定文章的ID,guid,標題,摘要,內容
get_the_ID()
get_the_guid(post_id)
get_the_title(post_id)
get_the_excerpt(post_id)
get_the_content('','',8)
 
調用搜索框
get_search_form();
html代碼調用
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<div>
<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" />
</div>
</form>
 
搜索頁代碼
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div><a href="<?php echo get_permalink($post->ID); ?>">
<?php the_title(); ?></a></div>
<?php endwhile; ?>
<?php else : ?>
<article> <header class="entry-header">
<h1 class="entry-title">
<?php _e( '沒有找到該文章', 'leizi' ); ?></h1> </header>
<div class="entry-content"> <p>
<?php _e( '抱歉沒有找到該文章', 'leizi' ); ?></p>
<?php get_search_form(); ?> </div> </article>
<?php endif; ?>
 
調用特色圖片
the_post_thumbnail(); 
// 無參數,默認調用Thumbnail the_post_thumbnail( 'thumbnail' ); 
// Thumbnail (默認尺寸 150px x 150px max) the_post_thumbnail( 'medium' ); 
// Medium resolution (default 300px x 300px max) the_post_thumbnail( 'large' ); 
// Large resolution (default 640px x 640px max) the_post_thumbnail( 'full' ); 
// Full resolution (original size uploaded) the_post_thumbnail(  array (100,100) ); 
// Other resolutions
 
$getThumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()),full);
echo $getThumbnail[0];
 
  
 
__()函數和__e()函數被用來識別php文件中被標示的、需要被翻譯成其它語言或本地化的字符串。
 
 
兩個函數間的唯一功能性區別在於:
 
_e()函數回顯(echo)返回的字符串,而__()函數只是返回字符串。如果需要爲函數提供字符串,可使用__()函數。而如果希望將字符串作爲XHTML的一部分輸出,則需要使用_e()函數。
 

站點信息調用


 

echo get_bloginfo('name').
echo get_bloginfo('description')
echo get_bloginfo('admin_email').
echo get_bloginfo('charset')
echo get_bloginfo('version')
echo get_bloginfo('language')
echo get_bloginfo('wpurl')
echo get_bloginfo('url')
echo get_bloginfo('template_url')
 
 
 
‘name’ – 返回站點標題,站點標題通過後臺控制面板 設置=》常規 中設置。
‘description’ – 返回站點副標題,站點副標題通過後臺控制面板 設置=》常規 中設置。
‘wpurl’ – 返回站點URL
‘url’ – 返回站點地址。
‘admin_email’ – 返回站點設置的郵件地址
‘charset’ – 返回站點的字符。
‘version’ – 返回wordpress版本.
‘html_type’ – 返回wordpress頁面的文檔類型(default: “text/html”).
‘text_direction’ -返回wordpress站點額描述信息.
‘language’ – 返回wordpress的語言,中文版是zh_CN。
‘stylesheet_url’ – 返回主題style.css的絕對路徑。
‘stylesheet_directory’ – 返回主題style.css的路徑。
‘template_url’ / ‘模板目錄’
‘pingback_url’ -返回站點 XML-RPC 文件的 URL (xmlrpc.php).
‘atom_url’ – 返回 Atom feed 地址 (/feed/atom).
‘rdf_url’ – 返回 RDF/RSS 1.0 feed 地址 (/feed/rfd).
‘rss_url’ – 返回 RSS 0.92 feed 地址 (/feed/rss).
‘rss2_url’ – R返回 RSS 2.0 feed 地址 (/feed).
‘comments_atom_url’ – 返回評論的 Atom feed URL (/comments/feed).
‘comments_rss2_url’ – 返回評論的 RSS 2.0 feed URL (/comments/feed).3
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章