显示内容仅发布评论者

时间:2012-12-23 22:01:02

标签: wordpress comments

我们可以在wordpress单页中隐藏我们的全部内容吗?

通常;我想为所有用户提供一些文本,而不是我的single.php上的完整帖子 等;

  

如果您阅读完整帖子请写下您的意见:)

如果用户评论了一个帖子我想向评论者显示完整的帖子是否可能?

任何帮助谢谢

Simple Single.php

<?php get_header();?>

<?php the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php comments_template(); ?>

<?php get_footer();?>

1 个答案:

答案 0 :(得分:0)

您可以这样做:

<?php
// Instead of function the_content() 
$Content = get_the_content();
echo string_limit_words( $Content, 15 ) . " ..."; //Where 15 is the number of words you want to display

// Place this function in "functions.php" in the style sheet directory
  if ( !function_exists( 'string_limit_words' ) ) {
    function string_limit_words( $string, $word_limit ) {
      $words = explode( ' ', $string, ( $word_limit + 1 ) );
      if ( count( $words ) > $word_limit ) array_pop( $words );
      return implode( ' ', $words );
    }
  }
?>
相关问题