多位作者在Wordpress的同一职位

问题描述:

我有一位朋友曾要求我为他和两位朋友建立一个网站来撰写电影评论。我对Wordpress很满意,所以它是该网站的明显选择。我唯一的困难是他们每个人都打算在同一部电影上写一篇评论,而我无法想象如何在一篇文章中实现多个作者。多位作者在Wordpress的同一职位

我已经签了几个插件,如共同执笔者加上它允许多个作者记入同一职位,但它并没有保持每个作者的内容单独提供的功能。

我能想到的唯一解决方法是使用自定义字段,但我宁愿如果作者可以使用他们的评论主要内容编辑器。任何帮助是极大的赞赏!

+0

应该是更好有1评论= 1发布,没有? – soju 2011-05-10 09:46:18

+0

最好,是的。把他们分组? – adamturtle 2011-05-10 14:19:40

就像我说的,最好有1条评论= 1条。

所以,我认为实现这一目标的最佳途径应该是创造文章类型:

  • 电影
  • 审查,电影基准场

而且修改后的模板显示电影和相关评论在同一页上。

另一种解决方法应该是使用分类处理电影及附加后给他们。

我遇到同样的问题,试图找出如何做到这一点也让我跟着烧酒的建议,并解决了上来。这可能有更好的解决方案,但这是我如何去做的。我和我的朋友正在做一个动漫评论博客,我和他都将在同一个动画上撰写评论。

我第一次创建了两个文章类型:

  • 动漫:主页上的特定动漫,喜欢的描述,图片等
  • 评论:笔者对动漫审查。我在这里启用的选项是编辑器,标题和作者。与相关的动画分类一起。这是所有在这里需要

然后,我创建了动漫标题的分类,所以当用户需要写上尚未添加为产品尚未有评论他们可以添加标题为分类的动漫进行审查。

我相关的分类既post_types和瓦拉!这几乎是你所需要的。

所以,现在当你想为新的动画写一个新的评论,你首先添加一个动画文章类型,并写下动画是关于和包括图片等。将标题添加到分类并检查它。之后,你创建一个帖子类型评论的新帖子,并写下你的评论,记得在你的分类标准中检查这个动画的正确标题,然后你就准备好了!

问题1:我如何将它包含到我的循环中?

嗯,你不希望包括在你的循环两种文章类型你只是想包括职位和你的循环其他职位类型的动画,这样你就在你的功能如下。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。所以在这种情况下,我为我的发布类型动画创建了一个single-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); 
    } 
?> 

你可以做更多的事情与此添加更多的分类法等。我实际上是通过添加一个分类法并添加一个标准来查找帖子部分来实现一个情节审查。希望这会帮助你,可能会有点晚:虽然谢谢烧酒推荐自定义帖子类型!