最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - How to query the custom fields by language?

programmeradmin2浏览0评论

For each post, there is a custom field name "Function", the key/value pair is like this:

Key : Functions
Value : <!--en-->Nourishing Yin and invigorating the vital essence of kidneys.<!--:--><!--tw-->滋陰補腎。<!--:-->

The problem is if I simply use get_post_meta , it return string of both language, how can I get the value based on the language?

I am using qTranslate right now, Thanks.

For each post, there is a custom field name "Function", the key/value pair is like this:

Key : Functions
Value : <!--en-->Nourishing Yin and invigorating the vital essence of kidneys.<!--:--><!--tw-->滋陰補腎。<!--:-->

The problem is if I simply use get_post_meta , it return string of both language, how can I get the value based on the language?

I am using qTranslate right now, Thanks.

Share Improve this question asked Jul 8, 2014 at 4:03 user3538235user3538235 1411 gold badge1 silver badge5 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

In qTranslate, there is this function that "dispatch" the language with the kind of string you have.

Haven't tested it yet, but you could do something like:

$myString = get_post_meta( $post_id, 'Functions', true);
echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($myMeta);

This will display the right language on your post based on the current page's language.

发布评论

评论列表(0)

  1. 暂无评论