images – obtener el título del archivo adjunto basado en la identificación del archivo adjunto

Pregunta:

getMeta una imagen a través de getMeta . Me devuelve la identificación del archivo adjunto. Ahora quiero obtener el título, el texto alternativo, la descripción, etc.

Para el texto alternativo, esto funciona muy bien:

get_post_meta($logo, '_wp_attachment_image_alt', true);

Ahora quiero conseguir el título. Descubrí que puedo hacer eso con $attachment->post_title , pero aquí solo tengo la identificación. ¿Cómo obtengo el título de una identificación de archivo adjunto?

Respuesta:

Si tiene la identificación del archivo adjunto, puede usar get_the_title()

$attachment_title = get_the_title($attach_id)

http://codex.wordpress.org/Function_Reference/get_the_title

Leave a Comment

Your email address will not be published. Required fields are marked *

web tasarım