Is this possible in WordPress

I am trying to do something I am unsure is possible and need a general direction. I have a WordPress 3.31 multi-site set up. I have several custom roles set up. Student, Teacher1, Teacher2, Teacher3, Family and Friends.

I also have several custom post types set up. The Teacher custom post type is what I am concerned with.

Read More

In the very near future we are going to have to add about 3000 blogs to this system. I would like the name of the custom post type to be the name of the person in the teacher role for that blog – automatically. There can be up to three teachers per blog.

So I am thinking somehow query the wp_usermeta for teacher role and then display the teacher’s name. in the custom post set up (below) It would have to loop up to three times since Students may have several teachers. Anyone out there have any idea if this is possible and a general direction?

I.E.

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

Related posts

Leave a Reply

2 comments

  1. I have a custom post type include I use. That roughly includes something like this:

    You could likely create something for the $types array that would help you accomplish what you need.

    <?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);
    
        }
    
    }
    
    ?>
    

    I’ve modified the $types array for you – if you need to adjust it hopefully you understand how to from this. If not I’ll probably need more information on it.