Wordprss taxonomy 是什麼

Taxonomy 的意思是一個分類學,wordpress 運用taxonomy 的地方很多,例如category(類別),tag(標籤),link category(連結分類)。到了2.3版本後,custom taxonomies 開始實現,用戶可以自定自己的分類

WordPress 是如何註冊一個taxonomy的?

利用下面的代碼可以建議一個”people”的taxonomy,文章類型是post

[php]
function people_init() {
// create a new taxonomy
register_taxonomy(
‘people’,
‘post’,
array(
‘label’ = __(‘People’),
‘sort’ = true,
‘args’ = array(‘orderby’ = ‘term_order’),
‘rewrite’ =array(‘slug’ = ‘person’)
)
);
}
add_action( ‘init’, ‘people_init’ );
[/php]

通常都會給這些特殊的分類自定風格主題,因此會給他們定義terms

the_terms( $post->ID, ‘people’, ‘People: ‘, ‘, ‘, ‘ ‘ );

如何列出主題呢?

query_posts( array( ‘people’ => ‘bob’, ‘posts_per_page’ => 10 ) );

 

根據風格主題文件查詢表可以知道,taxonomy 是先查詢taxonomy-taxonomy-term.php 再查詢taxonomy-taxonomy.php最後才是taxonomy.php

參考文章:http://codex.wordpress.org/Taxonomies

http://codex.wordpress.org/File:Template_Hierarchy.png

wordpress attachment images

最近做主題時要用到wordpress 附件圖片,在看數據庫時發現,原來每一個附件都是作為一個post插入數據庫,只是post-type不同,而且還有是屬於哪個post。在文章中也可以直接插入gallery。

看到這些功能,心動了,只是這些自帶的功能缺乏的東西就是附件圖片的描述。

根據說明,取得附件的function 是wp_get_attachment_image($id,size),這樣加一個foreach就能取得到post裡面的所有附件圖片,不過就是缺少介紹。

用google找到了一篇不錯的文件,寫了一個hack,可以取得附件圖片的title, description

[php]
/**
* Retrieves the attachment data such as Title, Caption, Alt Text, Description
* @param int $post_id the ID of the Post, Page, or Custom Post Type
* @param String $size The desired image size, e.g. thumbnail, medium, large, full, or a custom size
* @return stdClass If there is only one result, this method returns a generic
* stdClass object representing each of the image’s properties, and an array if otherwise.
*/
function getImageAttachmentData( $post_id, $size = ‘thumbnail’, $count = 1 )
{
$objMeta = array();
$meta;// (stdClass)
$args = array(
‘numberposts’ =$count,
‘post_parent’ =$post_id,
‘post_type’ = ‘attachment’,
‘nopaging’ =false,
‘post_mime_type’ =’image’,
‘order’ = ‘ASC’, // change this to reverse the order
‘orderby’ = ‘menu_order ID’, // select which type of sorting
‘post_status’ = ‘any’
);

$attachments = get_children($args);

if( $attachments )
{
foreach( $attachments as $attachment )
{
$meta = new stdClass();
$meta-ID = $attachment-ID;
$meta-title = $attachment-post_title;
$meta-caption = $attachment-post_excerpt;
$meta-description = $attachment-post_content;
$meta-alt = get_post_meta($attachment-ID, ‘_wp_attachment_image_alt’, true);

// Image properties
$props = wp_get_attachment_image_src( $attachment-ID, $size, false );

$meta-properties[‘url’] = $props[0];
$meta-properties[‘width’] = $props[1];
$meta-properties[‘height’] = $props[2];

$objMeta[] = $meta;
}

return ( count( $attachments ) == 1 ) ? $meta : $objMeta;
}
}

[/php]

如何使用:

[php]
getImageAttachmentData( $_posts-ID, ‘full’ );
[/php]

參考來源:http://www.farfromfearless.com/

http://www.newvibes.com/blog/wordpress-get-attachment-title-and-description/

白色iphone 4 ipad 2值得炒嗎?

假如你打算買來炒白色iphone 4,那麼請你先去先達問一下最新的收機價。今早5點也有朋友打來問我值不值得買來炒,不過我的答案還是否定的。

由昨晚凌晨開始,白色iphone4 16G收機價由7k 下跌到今早5.6k,跌價那麼快原因簡單,市場貨源十分充足,請看看SMV的計劃有何變動:

http://www.smartone-vodafone.com/jsp/iPhone4/tchinese/home.jsp

smv iphone4 white

看到上面的圖,有什麼特別?沒錯!!就是『儲值卡』計劃!只需要$5188就可以出一部白色iphone4 ,假如你是收機的人,買機的人成本那麼低,你會出高價收購嗎?最多給你賺幾百。不過你要冒上賣不出去的風險,也就是蟹貨(買入價高於現市價)。

另外,中國大陸很快也會推出白色iphone 4和ipad 2,基本上貨源充裕到內地都不想收,基本上賺也是賺匯率的差距。

假如要炒白色iphone 4 或ipad 2,請先做好功課,或者搶在全港人的隊前,不然,費了心思沒錢賺,所以要三思哦。

白色iphone 4 ipad2 香港正式發售

香港iphone 4 27號正式發售,個大電話供應商包括three, smart tone ,csl 都推出,smart tone 凌晨開始在中環戲院裡發售。

個人感覺只是換了個殼,OS版本為4.3.1,iphone 4 黑色貨源充足,不值得入貨炒。

蘋果新聞稿http://www.apple.com/pr/library/2011/04/27iphone.html

 

另外,ipad 2也29號開始發售,蘋果新聞稿:http://www.apple.com/pr/library/2011/04/27ipad.html

discuz x1.5 facebook connect

本人很懶很笨,一直想做discuz x1.5 的facebook connect都沒做,已經有UTF8,繁體和簡體版,十分支持開源!(雖然有風險)

主要討論地方都在這裡:http://www.discuz.net/thread-2108176-1-1.html

繁體http://www.alan888.com/Discuz/thread-189876-1-1.html

經過測試,此插件還有一些問題,並不是真正的facebook connect,而是一個帳號綁定,判斷也是根據uid 和facebook id,沒有像sina那樣,使用oauth來認證,還是要註冊,其實引用discuz x1.5 ucenter的機制是可以不用註冊的,不過還是可以用的,我用它來學習學習,還是有點用處的。

其實,這個插件被多人修改,各個都掛上自己的名字。

我第一次見到這個插件是在http://www.siamdiscuz.com作者positron.th@gmail.com,網站倒閉了,然後見到xileguo.com,把這個插件修改後用來賣錢。現在就出現這個版本,基本上內容都相似,但不是我想要的那種。

http://bbs.qxinnet.com/thread-41559-1-1.html