Support » Plugin: Category and Taxonomy Meta Fields » php code for custom field

  • Resolved cjrussell

    (@cjrussell)


    Hello, first of all, thank you for the plugin.

    I am very new to php and would like some guidance from you.

    I made a custom field for post tags called “video”. I simply want to call the field and display it based on the current page. What php code do I need to use? I have searched around for an answer, but nothing seems to be what I need.

    I am currently successfully calling and displaying the tag description this way:

    <?php echo category_description( $category_id ); ?>

    How can I call this custom “video” field this way?

    https://wordpress.org/plugins/wp-custom-taxonomy-meta/

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php
    if (function_exists('get_all_wp_terms_meta'))
    {
    $arrayMetaList = get_all_wp_terms_meta($category_id);
    }
    
    // array all meta fields for category/term
    print_r($arrayMetaList);
    ?>

    I have this inside the functions.php, now how do I display a particular field, like the “video” I referenced above?

    <?php
    if (function_exists('wp_get_terms_meta'))
    {
     $MetaValue = wp_get_terms_meta($category_id, 'video' ,true);
    }
    echo $metaValue;
    ?>

    I have this inside the widget to display the “video” field. Still isn’t working.

    Plugin Author Aftab Husain

    (@amu02aftab)

    Hi Cjrussell,

    Thanks for choosing my plugin.

    you can get value putting the below code in template page where you want fetch –

    <?php
    if (function_exists(‘wp_get_terms_meta’))
    {
    $MetaValue = wp_get_terms_meta($category_id, ‘video’ ,true);
    }
    echo $metaValue;
    ?>
    NOTE: Be sure you are passing correct $category_id in the above function.

    Hope this will help.

    If you are facing problem still you can mail me on amu02aftab at gmail com .

    Thanks,
    Aftab

    sir,
    Woo commerce category meta field short description is not work in the fronted .. Please give short code please

    https://www.vocalboothtogo.com/product-category/acoustic-sound-blankets-for-sound-absorption-producers-choice/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘php code for custom field’ is closed to new replies.