• 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/

Viewing 1 replies (of 1 total)
  • @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.