vendredi 26 avril 2019

Display post meta based on post category

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,
and 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