[……]
分類: 技術分享
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[……]
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_[……]
WPML fix get_posts() shows all languages problem
解決WPML使用get_posts(),會顯示所有文章列表,而不是顯示當前語言文章列表
$list = get_posts(array( 'showposts' => -1, 'post_type' => 'wpcf7_contact_form', 'post_status' => 'publish', ));
解決方法:
在參數中加上 ‘suppress_filters’ => false 即可,原因不明
$list = get_posts(array( 'showposts' => -1, 'post_type' => '[......]
WPML Ajax 無法取得翻譯文章
WPML Ajax 無法取得翻譯文章
使用WPML插件,使用Ajax取得文章,一直都沒辦法取得當前文章,只會取得預設語言文章,在這個問題上花費了好多時間,終於解決了!!!!
推測原因是WPML在 pre_get_posts 這個 hook 會override query_vars值,去對應翻譯文章分類,與得翻譯分類文章,在一般情況下是沒問題的,但使用Ajax要資料的時候,並沒有帶參數給WPML,以致WPML認為是預設語言,在 pre_get_posts 這個 hook 會override query_vars為預設語言,所以無法取得當前翻[……]
WordPress admin Remove notice and warning
本篇提供一個目前我用覺得很好用的方法,真正的刪除這些惱人的警告,之前有看過有些人的做法是用CSS去 display:none 這些提示與警告,然後假裝看不見,我覺得這樣很蠢,不是個好作法,你可以試試以下方法,也需幫的道你。[……]
WordPress 刪除 Divi theme project post type
[……]
List All Post Type
[……]
WordPress WP_Query() result posts object to an array
WordPress 原生帖子分頁頁碼 – 最簡單方法 the_posts_pagination()
the_posts_pagination( array $args = array() )
get_the_posts_pagination( array $args = array() )
基本上這兩個 function 是一樣的東西,只是一個是顯示出來,一個是回傳字串而已,都用在取得分頁頁碼,這兩個 function 的優點是使用非常簡單,依文章下方輸出的HTML格式套上CSS,帖子列表的分頁頁碼就實現了。
預設參數:
<?php $args = array( 'mid_size' => 1, 'prev_text'[......]