Title: [Plugin: Category Meta plugin] Extra code needed to make it work in PHP
Last modified: August 19, 2016

---

# [Plugin: Category Meta plugin] Extra code needed to make it work in PHP

 *  [bepresents](https://wordpress.org/support/users/bepresents/)
 * (@bepresents)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-category-meta-plugin-extra-code-needed-to-make-it-work-in-php/)
 * After adding “category_image” with the wp-admin=>Settings=>Category Meta window,
   I added an image to a category and was very impressed to see the Media Library
   interface!
 * Then I had to select the image and press “Insert into Post” even though I was
   inserting it into a Category.
 * And next I had to press Update on the Category Edit screen to save the changes.
 * Then I added this code to a PHP file, it works beautifully!
 * A+ on this plug-in!
 *     ```
       <?
       	if (function_exists('get_terms_meta'))
       	{
       		$imageURL = get_terms_meta($category_id, "category_image");
       	}
   
       	if(is_array($imageURL))
       	{
       		if(strlen($imageURL[0]))
       		{
       			echo("<img src='".$imageURL[0]."'>\n");
       		}
       	}
       ?>
       ```
   
 * [http://wordpress.org/extend/plugins/wp-category-meta/](http://wordpress.org/extend/plugins/wp-category-meta/)

Viewing 1 replies (of 1 total)

 *  [Dipak](https://wordpress.org/support/users/sarjya/)
 * (@sarjya)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-category-meta-plugin-extra-code-needed-to-make-it-work-in-php/#post-1645546)
 * [@bepresents](https://wordpress.org/support/users/bepresents/)
    Thanks a ton 
   for this! I was trying to add the KEYWORDS to Category pages. Your code helped.
 * To get the KEYWORDS for Categories, I updated the above code as:
 * >     ```
   >     $cat = $wp_query->get_queried_object();
   >     $category_id = $cat->term_id;
   >     if (function_exists('get_terms_meta'))
   >        {
   >         $keywords = get_terms_meta($category_id, 'cat_keywords');
   >        }
   >        if(is_array($keywords))
   >         {
   >         if(strlen($keywords[0]))
   >          {
   >     	echo("<meta name='keywords' content='".$keywords[0]."' />\n");
   >          }
   >        }
   >     ```
   > 
 * … and its working!
 * Cheers!
    – D

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Category Meta plugin] Extra code needed to make it work in PHP’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-category-meta.svg)
 * [Category Meta plugin](https://wordpress.org/plugins/wp-category-meta/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-category-meta/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-category-meta/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-category-meta/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-category-meta/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-category-meta/reviews/)

## Tags

 * [category meta](https://wordpress.org/support/topic-tag/category-meta/)
 * [image](https://wordpress.org/support/topic-tag/image/)

 * 1 reply
 * 2 participants
 * Last reply from: [Dipak](https://wordpress.org/support/users/sarjya/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-category-meta-plugin-extra-code-needed-to-make-it-work-in-php/#post-1645546)
 * Status: not resolved