Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hi! You can use the following code (obtained in https://developer.www.ads-software.com/reference/functions/get_term_meta/)

    <?php
    //TO USE IN SINGLE LOOP (single.php)
    //Get the category from the current post in the loop
    $category = get_the_category();
    
    //get_term_meta documentation https://developer.www.ads-software.com/reference/functions/get_term_meta/
    $color = get_term_meta($category[0]->cat_ID, 'color', true);
    
    //Check if it has a color
    if($color){
      echo '<h1 style="color:', $color , '">Category Color</h1>';
    }
    //
    //
    //
    //TO USE IN CATEGORY LOOP (category.php)
    //Get the category used in the loop
    $category = get_category( get_query_var( 'cat' ) );
    
    //get_term_meta documentation https://developer.www.ads-software.com/reference/functions/get_term_meta/
    $color = get_term_meta($category->cat_ID, 'color', true);
    
    //Check if it has a color
    if($color){
      echo '<h1 style="color:', $color , '">Category Color</h1>';
    }
    ?>
    • This reply was modified 8 years, 3 months ago by vitorhugojapa.
Viewing 1 replies (of 1 total)