Help with wordpress loop to generate api json

0

Hello, I would like a hangman here in this code:

'Object'=> get_the_nome da imagem que esta no destaque()

'Categoria' =>get_the_nome da categoria

follows the complete code:

$args = array( 'post_status' => 'publish');

$loop = new WP_Query( $args );

$array = array();

while ( $loop->have_posts() ) : $loop->the_post();

    global $data;
    $array[] = array(

        'Object'=> 'aqui apenas o nome da imagem destacada',
        'Titulo' => get_the_title(),
        'Descricao' => get_the_content(),
        'Categoria' => 'aqui o nome da categoria',
    );

endwhile;

wp_reset_query();
ob_clean();
echo json_encode($array);
exit();
    
asked by anonymous 31.12.2015 / 12:39

1 answer

5

For the name of the highlighted image to do various things, even get the title or alt from it.

For title:

get_the_title( get_post_thumbnail_id() )

For the alt attribute:

get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true )

    
01.01.2016 / 13:05