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

categories - Get value of custom field in category admin

programmeradmin1浏览0评论

I am using cfs-custom-category-fields plugin.

In their documentation it says that to get the value of a custom field in category you should use CfsTaxonomy::get('field_name')

This works well when I am in a category page, like category-24.php.

But it doesn't work in index.php.

How do I get the value in a non-category page? I tried something like this:

$cat_id = 29;
    if($cat_id=29){
        echo CfsTaxonomy::get('arata_in_listare');
    }?> 

But it doesn't work.

I suppose I need to create a category page-like environment.

I am using cfs-custom-category-fields plugin.

In their documentation it says that to get the value of a custom field in category you should use CfsTaxonomy::get('field_name')

This works well when I am in a category page, like category-24.php.

But it doesn't work in index.php.

How do I get the value in a non-category page? I tried something like this:

$cat_id = 29;
    if($cat_id=29){
        echo CfsTaxonomy::get('arata_in_listare');
    }?> 

But it doesn't work.

I suppose I need to create a category page-like environment.

Share Improve this question asked Sep 11, 2014 at 19:36 Claudiu CreangaClaudiu Creanga 5311 gold badge4 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You have to use this function: get_post_custom_values

The first parameter is the name of the key, arata_in_listare, and the second the post id, depending on where are you making the call you might not need to pass it.

In this community we don't give support for plugins, so I'm showing you the "wordpress" way of doing this.

发布评论

评论列表(0)

  1. 暂无评论