admin管理员组文章数量:1130349
I am trying to show custom excerpt using the_excerpt(). the full code is as follows:
<div id="content">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'post_type' => 'post', // You can add a custom post type if you like
'paged' => $paged,
'category_name' => 'technology',
'posts_per_page' => 10 // limit of posts
));
if ( have_posts() ){
$i = 0;
while ( have_posts() ) :
$i++;
the_post();
?>
<?php if($i%2 == 1){?>
<div class="row">
<?php } ?>
<div class="col-md-6">
<h3><a class="card-link" href="<?php echo the_permalink(); ?>"> <?php the_field('title_for_excerpt'); ?> </a> </h3>
<div class="row">
<div class="col-md-6">
<?php the_post_thumbnail('full', array('class' => 'rounded featured-image')); ?>
</div>
<div class="col-md-6 ">
<div class="exceprt-container"> <?php the_excerpt(); ?> </div>
<a class="btn btn-primary" href="<?php echo the_permalink(); ?>">বিস্তারিত </a>
</div>
</div>
</div>
<?php if($i%2 == 0){?>
</div>
<?php }
endwhile;
if($i%2 == 1){?>
</div>
<?php }
} ?> <!-- END have-post -->
<?php
But strange is: the excerpt is printing part of the actual content. But I input custom excerpt separately:
Any idea?
I am trying to show custom excerpt using the_excerpt(). the full code is as follows:
<div id="content">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'post_type' => 'post', // You can add a custom post type if you like
'paged' => $paged,
'category_name' => 'technology',
'posts_per_page' => 10 // limit of posts
));
if ( have_posts() ){
$i = 0;
while ( have_posts() ) :
$i++;
the_post();
?>
<?php if($i%2 == 1){?>
<div class="row">
<?php } ?>
<div class="col-md-6">
<h3><a class="card-link" href="<?php echo the_permalink(); ?>"> <?php the_field('title_for_excerpt'); ?> </a> </h3>
<div class="row">
<div class="col-md-6">
<?php the_post_thumbnail('full', array('class' => 'rounded featured-image')); ?>
</div>
<div class="col-md-6 ">
<div class="exceprt-container"> <?php the_excerpt(); ?> </div>
<a class="btn btn-primary" href="<?php echo the_permalink(); ?>">বিস্তারিত </a>
</div>
</div>
</div>
<?php if($i%2 == 0){?>
</div>
<?php }
endwhile;
if($i%2 == 1){?>
</div>
<?php }
} ?> <!-- END have-post -->
<?php
But strange is: the excerpt is printing part of the actual content. But I input custom excerpt separately:
Any idea?
Share Improve this question edited Nov 18, 2018 at 18:18 Brad Holmes 2151 silver badge11 bronze badges asked Nov 18, 2018 at 16:56 Abdus Sattar BhuiyanAbdus Sattar Bhuiyan 2232 silver badges16 bronze badges1 Answer
Reset to default 0One thing that can be happening is if you have added a Read more tag in your content it is overriding the manual excerpt. just check and see if you have <!--more--> tag in your content body. if so remove it.
The next thing is the_excerpt()may use auto generated excerpt. it is said in Wp Codex. what you want to use is the get_the_excerpt() method which will retrieve a set custom excerpt.
<?php if ( has_excerpt() ) : // Only show custom excerpts not autoexcerpts ?>
<div class="exceprt-container"><?php echo get_the_excerpt(); ?></div>
<?php endif; ?>
See get_the_excerpt() reference here
I am trying to show custom excerpt using the_excerpt(). the full code is as follows:
<div id="content">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'post_type' => 'post', // You can add a custom post type if you like
'paged' => $paged,
'category_name' => 'technology',
'posts_per_page' => 10 // limit of posts
));
if ( have_posts() ){
$i = 0;
while ( have_posts() ) :
$i++;
the_post();
?>
<?php if($i%2 == 1){?>
<div class="row">
<?php } ?>
<div class="col-md-6">
<h3><a class="card-link" href="<?php echo the_permalink(); ?>"> <?php the_field('title_for_excerpt'); ?> </a> </h3>
<div class="row">
<div class="col-md-6">
<?php the_post_thumbnail('full', array('class' => 'rounded featured-image')); ?>
</div>
<div class="col-md-6 ">
<div class="exceprt-container"> <?php the_excerpt(); ?> </div>
<a class="btn btn-primary" href="<?php echo the_permalink(); ?>">বিস্তারিত </a>
</div>
</div>
</div>
<?php if($i%2 == 0){?>
</div>
<?php }
endwhile;
if($i%2 == 1){?>
</div>
<?php }
} ?> <!-- END have-post -->
<?php
But strange is: the excerpt is printing part of the actual content. But I input custom excerpt separately:
Any idea?
I am trying to show custom excerpt using the_excerpt(). the full code is as follows:
<div id="content">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'post_type' => 'post', // You can add a custom post type if you like
'paged' => $paged,
'category_name' => 'technology',
'posts_per_page' => 10 // limit of posts
));
if ( have_posts() ){
$i = 0;
while ( have_posts() ) :
$i++;
the_post();
?>
<?php if($i%2 == 1){?>
<div class="row">
<?php } ?>
<div class="col-md-6">
<h3><a class="card-link" href="<?php echo the_permalink(); ?>"> <?php the_field('title_for_excerpt'); ?> </a> </h3>
<div class="row">
<div class="col-md-6">
<?php the_post_thumbnail('full', array('class' => 'rounded featured-image')); ?>
</div>
<div class="col-md-6 ">
<div class="exceprt-container"> <?php the_excerpt(); ?> </div>
<a class="btn btn-primary" href="<?php echo the_permalink(); ?>">বিস্তারিত </a>
</div>
</div>
</div>
<?php if($i%2 == 0){?>
</div>
<?php }
endwhile;
if($i%2 == 1){?>
</div>
<?php }
} ?> <!-- END have-post -->
<?php
But strange is: the excerpt is printing part of the actual content. But I input custom excerpt separately:
Any idea?
Share Improve this question edited Nov 18, 2018 at 18:18 Brad Holmes 2151 silver badge11 bronze badges asked Nov 18, 2018 at 16:56 Abdus Sattar BhuiyanAbdus Sattar Bhuiyan 2232 silver badges16 bronze badges1 Answer
Reset to default 0One thing that can be happening is if you have added a Read more tag in your content it is overriding the manual excerpt. just check and see if you have <!--more--> tag in your content body. if so remove it.
The next thing is the_excerpt()may use auto generated excerpt. it is said in Wp Codex. what you want to use is the get_the_excerpt() method which will retrieve a set custom excerpt.
<?php if ( has_excerpt() ) : // Only show custom excerpts not autoexcerpts ?>
<div class="exceprt-container"><?php echo get_the_excerpt(); ?></div>
<?php endif; ?>
See get_the_excerpt() reference here
本文标签: wp querycustom excerpt is not being shown
版权声明:本文标题:wp query - custom excerpt is not being shown 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749171267a2327046.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论