$wpdb get SQL string 取得mySQL查詢字串

$wpdb 取得MySQL查詢字串

WordPress 提供了 wpdb 這 Class 有很多方法可以操作資料庫,如果是用 wpdb 的內建方法來處理查詢,有時除錯會想看最終組出來送到資料庫的查詢字串,只要 echo $wpdb->last_query ,就可以取得囉。

範例:

參考:

[……]

Read more

WPML 筆記

常數

  ICL_LANGUAGE_CODE當前語言的Code
ex:zh-hant、ja、en

Functions

獲取預設語言碼

由翻譯文章取得主要與言文章id

$element_id
(int) (Required) The ID of the post type (post, page, attachment, custom post) or taxonomy term (tag, category, custom taxonomy) to filter
$element_type
(string) (Required) The typ[……]

Read more

WordPress thumbnail default size 預設縮圖尺寸表

WordPress 預設縮圖尺寸表

尺寸名 (字串)大小尺寸說明thumbnail小150 x 150 強制裁剪尺寸medium中等300 x 300 最大高度300像素medium_large中大768 x 無限高 WP4.4增加large 大1024 x 1024 最大高度1024像素full完整尺寸原始大小 

WooCommerce 預設縮圖尺寸表

尺寸名 (字串)大小尺寸說明shop_thumbnail小180 x 180強制裁剪尺寸shop_catalog中300 x 300強制裁剪尺寸shop_[……]

Read more

WordPress get_post_type() is Null

主題或插件中有時我們會用同一支程式重複使用,比如說主題的Banner,通常不會每一個頁面寫一次,而是每個頁面都會 include banner.php 檔案,這樣的好處是維護比較方便讓程式的再利用,但在banner.php中,不可能所有頁面banner全都一樣,所以在banner.php需要設定一些判斷條件,依據不同條件做不同的事。

範例:

<?php
$post_type = get_post_type( get_the_ID() );
if ( in_array( $post_type , array('page','post','custom_post_type_nam[......]

Read more

WordPress Fix TypeError: p.easing[this.easing] is not a function

Fix TypeError: p.easing[this.easing] is not a function

function v123_dev_main_scripts() {
        wp_enqueue_script('jquery');
        wp_enqueue_script('jquery-ui-core');
	wp_enqueue_script('jquery-effects-core');
}
add_action('wp_enqueue_scripts', 'v123_dev_main_scripts');

 [……]

Read more

WordPress admin Remove notice and warning

本篇提供一個目前我用覺得很好用的方法,真正的刪除這些惱人的警告,之前有看過有些人的做法是用CSS去 display:none 這些提示與警告,然後假裝看不見,我覺得這樣很蠢,不是個好作法,你可以試試以下方法,也需幫的道你。[……]

Read more

WordPress 插件宣告

任何插件的第一步,宣告這是個WordPress插件

在為您的項目分配版本號時,請記住,WordPress使用PHP version_compare() 函數來比較插件版本號。因此,在您發布新版本的插件之前,您應該確保這個PHP函數認為新版本比舊版本“更大”。

例如,1.02實際上大於 1.1。

[……]

Read more