mercredi 1 mai 2019

If statement to display Post meta

I have a taxonomy named talent_cat which is the category of said post, has 4 values: modelos, atores, musica, djs and inside each individual talent_cat there are these post meta keys:
talent_id_1495127471815 for modelos
talent_id_1495127471816 for atores
talent_id_1495127471817 for musica
talent_id_1495127471818 for djs

How can I build a conditional to show the right post meta depending on the talent_cat of said post? So if the post belongs to talent_cat = modelos it returns the talent_id_1495127471815 and not the other values.

I tried this but unsuccessfully:

$talent_data = get_the_term_list( $post->ID, 'talent_cat');
switch( $talent_data ) {
                case 'modelos':
                    echo get_post_meta(get_the_ID(), 'talent_id_1495127471815', true);
                    break;
      }

Thanks.

Aucun commentaire:

Enregistrer un commentaire