Category Archives: wordpress

wordpress 開發插件必看文章

要開發wordpress 插件,當然少不了就是要熟悉一下wordpress的環境,然後再看開發說明啦。不過說明書實在太多了,如何入手都成問題,多數還是會參考別人的插件,再設計自己的插件。要上手,還是有些文章值得參考。 1. 教學:如何開發wordpress 插件 http://www.devlounge.net/extras/how-to-write-a-wordpress-plugin 十分詳細 2.官方開發說明書 http://codex.wordpress.org/Developer_Documentation 3.官方提供插件開發資源 http://codex.wordpress.org/Plugin_Resources wordpress 有個十分重要的概念就是hook,因此要了解清楚。 插件開發有幾個十分重要,就喺action, filter,post,loop等,下面推薦收藏 http://codex.wordpress.org/Plugin_API http://codex.wordpress.org/The_Loop filter 介紹:http://codex.wordpress.org/Plugin_API/Filter_Reference 插入文章tag: http://codex.wordpress.org/Function_Reference/add_shortcode http://codex.wordpress.org/Function_Reference/add_filter

Posted in wordpress | Tagged , , | Leave a comment

wordpress wp ecommerce last product

wordpress 設計theme 時需要在首頁取得wp ecommerce 的最新產品資料,可以用以下方法,輸出圖片,和title,網上找沒什麼資料,只好自己在widget 改一下那來用 global $wpdb; $args = wp_parse_args( (array)$args, array( 'number' => 5 ) ); $number = 3; $image = true; $width = 150; $height = 150; $latest_products = get_posts( array( 'post_type' => 'wpsc-product', 'numberposts' => $number, … Continue reading

Posted in php, wordpress | Tagged , , | Leave a comment

wordpress 判斷首頁

wordpress theme 製作記錄 今日製作到sidebar 時,突然常用的is_front_page() 不能使用,於是改用了is_home() 代之,又正常了,沒有時間去查證,初步估計可能是因為設定了首頁為某指定頁面有關。

Posted in wordpress | Tagged , , , | Leave a comment

wordpress 自定rss 內容

wordprss 可以選擇訂閱內容全部顯示或部分顯示,假如部分顯示,也許有些東西在底部推薦給讀者的看不到,這裡有個方法,在function 裡面加上一段 if ( !function_exists('custom_feed_footer') ){        function custom_feed_footer($content)         {                if(is_feed())                $content .= '自定內容';              … Continue reading

Posted in Code, wordpress | Tagged , , , | 1 Comment

Wordprss taxonomy 是什麼

Taxonomy 的意思是一個分類學,wordpress 運用taxonomy 的地方很多,例如category(類別),tag(標籤),link category(連結分類)。到了2.3版本後,custom taxonomies 開始實現,用戶可以自定自己的分類 WordPress 是如何註冊一個taxonomy的? 利用下面的代碼可以建議一個”people”的taxonomy,文章類型是post 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') ) ); } … Continue reading

Posted in wordpress | Leave a comment

wordpress attachment images

最近做主題時要用到wordpress 附件圖片,在看數據庫時發現,原來每一個附件都是作為一個post插入數據庫,只是post-type不同,而且還有是屬於哪個post。在文章中也可以直接插入gallery。 看到這些功能,心動了,只是這些自帶的功能缺乏的東西就是附件圖片的描述。 根據說明,取得附件的function 是wp_get_attachment_image($id,size),這樣加一個foreach就能取得到post裡面的所有附件圖片,不過就是缺少介紹。 用google找到了一篇不錯的文件,寫了一個hack,可以取得附件圖片的title, description /** * 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 … Continue reading

Posted in Code, wordpress | Leave a comment