2012-04-01 25 views
2

我想做的事情,我不确定是可能的,需要一个大方向。我有一个WordPress的3.31多站点设置。我有几个自定义角色设置。学生,老师1,老师2,老师3,家人和朋友。这是可能的Wordpress

我也有几个自定义的帖子类型设置。教师自定义帖子类型是我所关心的。

在不久的将来,我们将不得不增加大约3000个博客到这个系统。我希望自定义帖子类型的名称成为该博客的教师角色中的人员名称。每个博客最多可以有三位教师。

所以我想不知何故查询教师角色的wp_usermeta,然后显示教师的名字。在设置的自定义帖子中(下面)由于学生可能有几位教师,因此必须循环三次。那里的任何人有任何想法,如果这是可能的和一个大方向?

I.E.

register_post_type('journal_teacher', 
    array(
     'labels' => array(
      'name' => __(query-here-for-teacher-role)),... 
+0

如果您的问题在标题中,您的问题将会更加成功。例如:我如何制作动态命名的WordPress自定义文章类型?此外,WordPress的堆栈交换可能与您的兴趣相关。 http://wordpress.stackexchange.com/ – DingoEatingFuzz 2012-04-02 00:26:14

回答

1

如果你在转弯的WordPress到LMS系统我强烈建议你使用课件,http://coursewa.re/思考。它会帮助你很多。

+0

感谢您的提示DingoEatingFuzz - 将做;-) – user10660 2012-04-03 03:47:04

1

我有一个自定义的帖子类型包括我使用。这大致包括这样的东西:

你可能会创建一些$ types数组,可以帮助你完成你所需要的。

<?php 
// ADDING CUSTOM POST TYPE 
add_action('init', 'all_custom_post_types'); 

function all_custom_post_types() { 

    $types = array(

     // Student 
     array('the_type' => 'students', 
      'single' => 'Student', 
      'plural' => 'Students', 
      'hierarchical' => true, 
      'support' => array('title','editor','thumbnail','custom-fields'), 
      'taxonomy' => array('')), 

     // Teacher1 
     array('the_type' => 'teacher1', 
      'single' => 'Teacher1', 
      'plural' => 'Teachers1', 
      'hierarchical' => true, 
      'support' => array('title','editor','thumbnail','custom-fields'), 
      'taxonomy' => array('')), 

     // Teacher2 
       array('the_type' => 'teacher2', 
        'single' => 'Teacher2', 
        'plural' => 'Teachers2', 
        'hierarchical' => true, 
        'support' => array('title','editor','thumbnail','custom-fields'), 
        'taxonomy' => array('')), 

       // Teacher3 
       array('the_type' => 'teacher3', 
        'single' => 'Teacher3', 
        'plural' => 'Teachers3', 
        'hierarchical' => true, 
        'support' => array('title','editor','thumbnail','custom-fields'), 
        'taxonomy' => array('')), 

       // Family and Friends - not sure if this is 2 or 1 category - but you get the idea by now. 
       array('the_type' => 'family-and-friends', 
        'single' => 'Family and Friends', 
        'plural' => 'Family and Friends', 
        'hierarchical' => true, 
        'support' => array('title','editor','thumbnail','custom-fields'), 
        'taxonomy' => array('')) 

     ); 

    foreach ($types as $type) { 

     $the_type = $type['the_type']; 
     $single = $type['single']; 
     $plural = $type['plural']; 

     $labels = array(
     'name' => _x($plural, 'post type general name'), 
     'singular_name' => _x($single, 'post type singular name'), 
     'add_new' => _x('Add New', $single), 
     'add_new_item' => __('Add New '. $single), 
     'edit_item' => __('Edit '.$single), 
     'new_item' => __('New '.$single), 
     'view_item' => __('View '.$single), 
     'search_items' => __('Search '.$plural), 
     'not_found' => __('No '.$plural.' found'), 
     'not_found_in_trash' => __('No '.$plural.' found in Trash'), 
     'parent_item_colon' => '' 
    ); 

     $args = array(
     'labels' => $labels, 
     'public' => true, 
     'publicly_queryable' => true, 
     'show_ui' => true, 
     'query_var' => true, 
     'rewrite' => true, // $rewriter, 
     'capability_type' => 'post', 
     'hierarchical' => $type['hierarchical'], 
     'menu_position' => 5, 
     'supports' => $type['support'] 
    ); 

     register_post_type($the_type, $args); 

    } 

} 

?> 

我已经修改了$类型数组为你 - 如果你需要调整它希望你了解如何从这个。如果没有,我可能需要更多的信息。

+0

感谢您对此...我不是一个先进的PHP编码器,并希望了解这一点。如果我使用函数get_users/get_user_meta'抓取'与$类中的博客相关联的教师ID,那么我可以在我的标签数组中使用该变量作为自定义帖子类型的教师?感谢您的任何额外的指示... – user10660 2012-04-07 15:10:24

+0

这绝对是让我在正确的方向 - 现在我只需要通过博客id与教师角色的老师的名字来做到这一点 - 谢谢你的开始;-)不知道如何要做到这一点 - 但会玩耍,看看我的位置 - 非常感谢您的帮助! – user10660 2012-04-08 17:57:00

+0

@Mike:user10660 [试图修改你的答案](http://stackoverflow.com/suggested-edits/236556) - 一些内容看起来很有用,但我不太了解这一点。用它来做什么。 (什么都没做就好了。) – sarnold 2012-04-09 00:17:36