Wordpress中同一帖子上的多个作者

时间:2011-05-10 04:39:54

标签: wordpress

我有一位朋友要我为他和两个朋友建一个网站来写电影评论。我对Wordpress非常好,所以这是该网站的明显选择。我唯一的困难是他们每个人都打算在同一部电影上写一篇评论,我想不出如何在一篇文章中找到多位作者。

我已经检查了一些插件,例如Co-Author Plus,它允许多位作者记入同一篇文章,但它没有提供保持每位作者内容分开的功能。

我能想到的唯一解决方案是使用自定义字段,但我更希望作者可以使用主要内容编辑器进行评论。非常感谢任何帮助!

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,试图弄清楚如何做到这一点,我遵循了soju的建议并想出了一个解决方案。可能有更好的解决方案,但这就是我的方法。我和我的朋友正在做一个动漫评论博客,我和他都会写同一部动漫的评论。

我首先创建了两种帖子类型:

  • 动漫:特定动漫的主页,如描述,图片等
  • 评论:作者对动漫的评论。我在这里启用的选项是编辑器,标题和作者。以及相关的动漫分类。这就是所需要的一切

然后我为动画片名创建了一个分类法,所以当用户需要为尚未添加为评论的动画写评论时,他们可以将标题添加到分类中。

我将分类法与post_types和wala联系起来!这几乎就是你所需要的。

所以现在当你想为新的动漫写一个新的评论时,你首先添加一个动漫帖子类型并写下动漫的内容并包括图片等。将标题添加到分类中并检查它。然后你创建一个帖子类型评论的新帖子并写下你的评论,记得检查你的分类中的正确标题,看看动画是什么,然后你准备好了!

问题1:如何将其包含在循环中?

你不想在你的循环中包含两种帖子类型你只想在你的循环中包含帖子和其他帖子类型动画,所以你在functions.php文件中执行以下操作:

function include_custom_post_types( $query ) { 
    global $wp_query;
    // Get all custom post types
    $custom_post_type = get_query_var( 'post_type' );
    // Get all post types
    $post_types = get_post_types();

    // If what you are getting is a category or a tag or that there are no custom
    // post types you just want to set the post types to be the current post types          
    if ( (is_category() || is_tag()) && empty( $custom_post_type ))
       $query->set( 'post_type' , $post_types );

    // Set the custom post types you want to ignore
    $ignore_types = array('reviews');

    //Unset the post types that are gonna be ignored
    foreach($post_types as $key=>$type)
    {
       if(in_array($type,$ignore_types))
       {
          unset($post_types[$key]);
       }
    }

    // Set the post types for the query
    if ( (is_home() && false == $query->query_vars['suppress_filters']) || is_feed())
         $query->set( 'post_type', $post_types);

    return $query;
}
add_filter( 'pre_get_posts' , 'include_custom_post_types' );

问题2:如何显示评论?

我通过创建另一个single.php文件解决了这个问题,并将其重命名为single-post_type_name.php。所以在这种情况下,我为我的帖子类型动漫创建了一个单一的anime.php文件。然后代替我希望得到这个特定动画的所有评论的内容,所以我在主要内容区域的文件中添加了以下内容:

<?php  
    //You grab the taxonomy that you have selected for this post
    $terms = wp_get_post_terms(get_the_ID(), 'animes_reviewed');
    // This is the args array for the criteria that the posts need to be in
   $args = array(
       // This is the post type of where your reviews are at
       post_type' => 'reviews',
       // this is for searching the taxonomy usually it's 
       // taxonomy_name => checked_taxonomy
       'anime' => $terms[0]->name, 
       'post_status' => 'publish'
    );

    // Grab the posts
    $posts = get_posts($args);

    //Here I echo out the information for debugging purpose, but 
    //Here is where you can do HTML to display your reviews
    foreach($posts as $post)
    {
        echo($post->post_content);
        the_author_meta( 'nickname', $post->post_author);
    }
?>

你可以通过添加更多分类法等来做更多事情。我实际上只是通过添加分类法并在帖子部分添加标准来实现一集。希望这会帮助你,虽然可能有点晚了:(感谢soju推荐自定义帖子类型!

答案 1 :(得分:0)

就像我说的那样,最好有1篇评论= 1篇。

所以,我认为实现这一目标的最佳方法应该是创建帖子类型:

  • 电影
  • 使用电影参考字段审核

修改帖子模板以在同一页面上显示电影和相关评论。

另一种解决方案应该是使用分类法处理电影并附上帖子。