• Resolved morris373

    (@morris373)


    Hi
    I created an taxonomy page called taxonomy-clergy.php and I can retrieve the Clergy’s name but how do you get the Custom fields for that clergy as well?

    To get the Clergy’s Name I used within the PHP template:

    echo get_the_term_list( $post->ID, 'clergy', '', ', ' );

    I searched the Pods website and have looked at most topics in this forum and found nothing and I even searched Google.

    I am not a WordPress or PHP programmer so I need just a little help and I will be alight once I have seen how it’s done.

    Thanks

    Morris

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

    (@morris373)

    Hi
    I have eventually found this piece of code and have adapted it to my Taxonomy’s custom fields:

    $clergy_title = pods_field('clergy', get_the_ID(), 'clergy_title', $single=true);

    I then echo’d it out and it doesn’t work, so where am I going wrong?

    Thanks

    Morris

    Thread Starter morris373

    (@morris373)

    Hi again
    I have got it working now by adding this code as the code wanted the ID or the category slug and I was already getting the category slug within the template so I just replaced it with that:

    $case_study_cat_slug = get_queried_object()->slug;
    $case_study_cat_name = get_queried_object()->name;
    $clergy_title = pods_field('clergy', $case_study_cat_slug, 'clergy_title', 
    $single=true);
    <h2><?php echo $case_study_cat_name . ' - ' . $clergy_title; ?></h2>

    I will know now how to get the other values if needed i.e. learn by example.

    Thanks

    Morris

    • This reply was modified 3 years, 10 months ago by morris373.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @morris373

    pods_field or pods_field_display are indeed the functions you can use for this.
    Other than that you can use the default WordPress functions like get_post_meta(), it will do the same think for the most part.
    So in your case I’d use: echo get_post_meta( get_the_ID(), 'clergy_title', true );

    Cheers, Jory

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add Custom Fields in Taxonomy to PHP File’ is closed to new replies.