How Add New Custom Fields On Taxonomy/Category Page Using Hooks Part-2:WordPress


Hello Friends!

Hope you all are doing well 🙂

In my last post i have explain to you  all my friends a way for  “add a new “Custom Fields” on taxonomy/category page
https://raghunathgurjar.wordpress.com/2014/04/14/how-add-new-custom-fields-on-taxonomycategory-page-using-hooks-wordpress/

Now i am going to explain you for show the newly added custom field and its value on “Category List” page

custom-filed

For do that you have need only to use my code and follow steps give below:

Steps.1 – First of all you have need to add given code in your theme function file

//For add the new fields 
function my_column_header($columns)
{
    $columns['customval'] = __('Custom Field');
    return $columns;
}
add_filter('manage_edit-category_columns', 'my_column_header', 10, 2);

After add this code in your theme function file you will be see the custom fields title

title

Step.2 – Now you have need to add the given code in your theme function for get the custom field value

//Get the custom field value
function my_column_value($empty = '', $custom_column, $term_id)
{
    //Category custom field
   $term_meta = get_option( "taxonomy_term_$term_id" ); 
   $CustomValue=$term_meta['wpsc_product_category_catsortby'] ? $term_meta['category_customval'] : '0';
       
 return $CustomValue;
}
add_filter('manage_category_custom_column', 'my_column_value', 10, 3);

 

That’s All 🙂

Enjoy Code! | Raghunath Blog

 

Advertisements

Sr. Software Engineer

Tagged with: , , , ,
Posted in Wordpress
One comment on “How Add New Custom Fields On Taxonomy/Category Page Using Hooks Part-2:WordPress
  1. Vallie says:

    I am truly thankful to the holder of this website who has shared this wonderful post at at this place.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: