• 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://ww.wp.xz.cn/plugins/wp-custom-taxonomy-meta/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter cjrussell

    (@cjrussell)

    <?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?

    Thread Starter cjrussell

    (@cjrussell)

    <?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

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘php code for custom field’ is closed to new replies.