admin管理员组文章数量:1319953
I have a problem.
It is <?php the_excerpt(); ?>
empty from gutemberg <?php the_excerpt(); ?>
pull little part of content from post but first next <?php the_permalink(); ?>
under is broken and changed path from single blog to root of list of blog posts.
How to fix that?
E.g of the loop:
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => 'post',
'posts_per_page' => 5,
'paged' => $paged
);
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
while($post_query->have_posts() ) {
$post_query->the_post();
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'blog-thumb');
?>
<div class="blog-item">
<?php if($featured_img_url) { ?>
<a href="<?php the_permalink(); ?>"><img src="<?php echo $featured_img_url; ?>" class="blog-thumb" id="img" alt=""></a>
<?php } ?>
<a href="<?php the_permalink(); ?>">
<h2 class="blog-title"><?php the_title(); ?></h2>
</a>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?> // broken link return to url/blog not url/single-blog-url" class="blog-btn">Read more</a>
</div>
<?php
}
}
?>
I have a problem.
It is <?php the_excerpt(); ?>
empty from gutemberg <?php the_excerpt(); ?>
pull little part of content from post but first next <?php the_permalink(); ?>
under is broken and changed path from single blog to root of list of blog posts.
How to fix that?
E.g of the loop:
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => 'post',
'posts_per_page' => 5,
'paged' => $paged
);
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
while($post_query->have_posts() ) {
$post_query->the_post();
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'blog-thumb');
?>
<div class="blog-item">
<?php if($featured_img_url) { ?>
<a href="<?php the_permalink(); ?>"><img src="<?php echo $featured_img_url; ?>" class="blog-thumb" id="img" alt=""></a>
<?php } ?>
<a href="<?php the_permalink(); ?>">
<h2 class="blog-title"><?php the_title(); ?></h2>
</a>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?> // broken link return to url/blog not url/single-blog-url" class="blog-btn">Read more</a>
</div>
<?php
}
}
?>
Share
Improve this question
asked Oct 16, 2020 at 13:31
Milosh N.Milosh N.
2152 silver badges8 bronze badges
1
|
1 Answer
Reset to default 0If it only breaks when the excerpt is empty, then I would check for the excerpt before outputting it.
<?php if ( ! empty( get_the_excerpt() ) : ?> // test for the excerpt
<?php echo esc_html( get_the_excerpt() ); ?> // escape the excerpt in case there is html added
<?php endif; ?>
本文标签: permalinksEmpty theexcerpt() broke thepermalink() under him
版权声明:本文标题:permalinks - Empty the_excerpt() broke the_permalink() under him? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742055584a2418273.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
the_excerpt
hook? If so, try disabling that filter and see if it helps. – Sally CJ Commented Oct 16, 2020 at 14:47