对于左侧,你可以这样做,
<?php
$args = array(
  \'post_type\'      => \'post\',
  \'posts_per_page\' => 10,   
  \'paged\'          => get_query_var(\'paged\') ? get_query_var(\'paged\') : 1,
);
$loop = new WP_Query( $args );
// add custom function before loop, so you can apply excerpt filter only to this case
do_action(\'my_custom_pre_loop_action\');
// is url parameter set, if so force it to integer
$current_post_id = ! empty( $_GET[\'postid\'] ) ? absint($_GET[\'postid\']) : 0;
while ( $loop->have_posts() ) : $loop->the_post();
  $post_class = \'et_blog_post\';
  // is the current loop item the same as the post in view?
  if ( get_the_id() === $current_post_id ) {
    $post_class .= \' active\';
  } else if ( 0 === $loop->current_post ) {
    $post_class .= \' active\' // make first post active as a fallback
  }
?>
  <article id="post-<?php the_ID(); ?>" class="<?php echo $post_class ?>">
    <div class="entry-content">   
      <h3 class="entry-title">  
        <a href="/blog/?postid=<?php the_ID(); ?>#post">
          <?php the_title(); ?>
        </a>
      </h3>
      <div class="post-content">
        <div class="post-content-inner">
          <?php the_excerpt(); ?>
        </div>
        <p>
          <a href="/blog/?postid=<?php the_ID(); ?>#post" class="blog-read-more">READ MORE</a>
        </p>  
      </div>
    </div>
  </article>
<?php 
endwhile;
// reset global $post after custom WP_Query loop
wp_reset_postdata();
 而不是将摘录长度设置为
substr(), 您可以使用
excerpt_length 滤器在上面的示例中,我添加了自定义操作,该操作添加了长度过滤器,以便它仅在该上下文中发生,而不是在站点范围内发生。
// apply custom exerpt lenght only when your custom action is fired
add_action(\'my_custom_pre_loop_action\', \'apply_my_custom_exerpt_length\');
function apply_my_custom_exerpt_length() {
  // if you want to apply this globally on your site then just move the add_filter to your functions.php
  add_filter(\'excerpt_length\', \'my_custom_exerpt_length\');
}
function my_custom_exerpt_length($length) {
  return 100;
}
 为了完整起见,比如右侧,
<?php
$current_post_id = ! empty( $_GET[\'postid\'] ) ? absint($_GET[\'postid\']) : 0;
$post = get_post( $current_post_id );
?>
<div class="entry-content">
  <?php if ( $post ) : ?>
    <h1><?php echo get_the_title($post); ?></h1>
    <?php echo apply_filters( \'the_content\', get_the_content($post) ); ?>
  <?php endif; ?>
</div>