0

Cómo puedo hacer para mostrar un artículo con un layout totalmente diferente para los artículos que tengan imagen destacada y otro layout, para los artículos que no tiene imagen destacada

1 respuesta 1

1

Puedes hacer algo así dentro de tu template:

single.php

<?php

get_header();

if ( have_posts() ) {
    while ( have_posts() ) {
        the_post();
        if ( has_post_thumbnail() ) {
            get_template_part('views/post-with-featured-image');
        } else {
            get_template_part('views/post-without-featured-image');
        }
    }
}

get_footer();

views/post-with-featured-image.php

<h1><?php the_title(); ?></h1>
<?php the_post_thumbnail('full'); ?>

views/post-without-featured-image.php

<h1><?php the_title(); ?></h1>

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.