How can I do to show an article with a totally different layout for articles that have a prominent image and another layout, for articles that do not have a prominent image?
How can I do to show an article with a totally different layout for articles that have a prominent image and another layout, for articles that do not have a prominent image?
You can do something like that inside your 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>