I have created the file content.php that contains now:
<article class="post <?php if (has_post_thumbnail() ) { ?>has-thumbnail <?php } ?>">
<!-- post-thumbnail -->
<div class="post-thumbnail">
<?php if (is_single() ) {?>
<?php the_post_thumbnail('banner-image');
} else {?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('small-thumbnail');
}?></a>
</div><!-- /post-thumbnail -->
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="post-info"><?php the_time('j. n. Y G:i'); ?> | od <a href="<?php get_author_posts_url(get_the_author_meta('ID')); ?>"><?php the_author()?></a> | Publikováno v
<?php
$categories = get_the_category();
$separator = ", ";
$output = '';
if($categories) {
foreach ($categories as $category) {
$output .= '<a href=" ' . get_category_link($category->term_id) . ' ">' . $category->cat_name . '</a>' . $separator;
}
echo trim($output, $separator);
}
?>
</p>
<?php if (is_single() ) {
the_content();
} elseif ( is_search() OR is_archive() ) {?>
<p>
<?php echo get_the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">?íst dál»</a>
</p>
<?php } else {
if ($post->post_excerpt) { ?>
<p>
<?php echo get_the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">?íst dál»</a>
</p>
<?php } else {
the_content();
}
} ?>
</article>
and I would like to remove the undesirable if-conditions is_single()
in the content.php. I would like to create specific file single.php that will correspond the format of the post chosen in the WordPress backend.
Unfortunately I can’t do it now because I don’t know the suitable code in single.php to respect the type of the post.
If I write the line get_template_part('content', get_post_format())
to the single file then the condition is_single()
will be called automatically “in the single.php” (I know that I am in single file so it is easier write there the code to respect the format directly).
-
This reply was modified 7 years, 9 months ago by
happik.
-
This reply was modified 7 years, 9 months ago by
happik.
-
This reply was modified 7 years, 9 months ago by
happik.