My-Meta-Box icon indicating copy to clipboard operation
My-Meta-Box copied to clipboard

Select Field. How to display the name... not the id

Open Nanosergio opened this issue 2 years ago • 0 comments

First of all, thanks for this wonderful class.

Using WordPress native function get_the_title() doesn't work for me :(

$my_meta->addSelect($prefix.'select_concurso_destinatarios',array('destinatario1'=>'Estudiantes de Grado','destinatario2'=>'Estudiantes de Máster','destinatario3'=>'Estudiantes de Doctorado','destinatario4'=>'Estudiantes sin nivel especificado','selectkey5'=>'No especificado'),array('name'=> 'Destinatarios', 'multiple'=>true));

<?php echo get_post_meta( $post->ID, 'ba_select_concurso_destinatarios', true );?> When I fill this field it displays: Result: destinatario1

<?php echo get_the_title(get_post_meta( $post->ID, 'ba_select_concurso_destinatarios', true ));?> When I fill this field it displays: Result: When empty it shows the title of the post Result: Michelin Challenge Design “Inspiring Mobility”

It worked for post fields but not for select field.

Nanosergio avatar Mar 27 '22 16:03 Nanosergio