Working with People Extension

The People extension (t2/people) provides a complete solution for managing and displaying team members, employees, or any people-based content in WordPress. It registers a custom post type with taxonomies and custom fields specifically designed for person profiles.

link For End Users

link What Does This Extension Do?

The People extension allows you to:

link Features Available

link Post Type: Person

link Taxonomies

link Contact Information Fields

link Custom Blocks

link How to Use

  1. Enable the Extension

    • Go to WordPress Admin → T2 Settings
    • Enable the "People" extension
    • Or add to your theme's t2.json: "mu-extensions": ["t2/people"]
  2. Create People Entries

    • Navigate to "People" in the WordPress admin menu
    • Click "Add new"
    • Fill in the person's name (post title)
    • Add a featured image for their photo
    • Select their role(s) and department(s)
    • Add email, phone, and other contact details in the sidebar
  3. Display People on Your Site

    • Use the Featured Content Layout block to display people in grids
    • Add the People Meta block inside person single posts to show contact info
    • The extension automatically creates a custom card template for the Featured Content block
  4. Configure Options

    • Edit your theme's t2.json file to customize behavior
    • See Configuration Options section below

link Screenshots & Examples

Default Card View: Shows featured image, name, role, department, email, and phone
Extended Card View: Includes mobile number and bio when enabled
Edit View: Custom meta boxes for all person fields in the WordPress editor


link For Developers

link Architecture

link File Structure

packages/extension-library/src/people/
├── block-library/
│   └── people-meta/          # Block for displaying person metadata
│       ├── block.json
│       ├── block.php
│       └── editor.js
├── extension.json            # Extension metadata
├── extension.php             # Entry point
├── namespace.php             # Core functionality
├── constants.js              # JS constants
├── index.js                  # Frontend JS initialization
├── view.js                   # Frontend interactions
└── style.css                 # Frontend styles

link Registration Pattern

The extension follows T2's standard pattern:

  1. extension.php loads namespace.php
  2. namespace.php calls boot() which hooks into WordPress
  3. Post type, taxonomies, and meta are registered on init hook
  4. Blocks are auto-discovered via load_blocks_in_extension('people')

link Configuration Options

All configuration is done via t2.json in your theme root:

{
  "version": 1,
  "mu-extensions": ["t2/people"],
  "t2/people": {
    "postTypeKey": "person",
    "features": {
      "hasArchive": false,
      "rewriteSlug": "people",
      "hasSinglePost": false,
      "hasRole": true,
      "hasDepartment": true,
      "hasEmail": true,
      "hasPhone": true,
      "hasMobile": false,
      "hasBio": false
    }
  }
}

link Configuration Reference

Key Type Default Description
postTypeKey string "person" Custom post type slug
features.hasArchive boolean false Enable post type archive page
features.rewriteSlug string|false false Custom URL slug (e.g., "team")
features.hasSinglePost boolean false Enable single post pages with per-post visibility control
features.hasRole boolean true Enable Role taxonomy
features.hasDepartment boolean true Enable Department taxonomy
features.hasEmail boolean true Enable email field
features.hasPhone boolean true Enable phone field
features.hasMobile boolean false Enable mobile phone field
features.hasBio boolean false Enable bio/description field

link Post Meta Keys

The extension registers the following post meta fields (based on feature flags):

All meta fields are exposed via REST API (show_in_rest: true).

link Taxonomy Keys

The extension registers two taxonomies:

Both default keys can be overridden via filters (see Hooks & Filters section).

link Hooks & Filters

link Filters

t2/extension/people/key_role
Override the role taxonomy key (default: "role"):

add_filter( 't2/extension/people/key_role', function( $key ) {
    return 'job_title'; // Use 'job_title' instead of 'role'
} );

t2/extension/people/key_department
Override the department taxonomy key (default: "department"):

add_filter( 't2/extension/people/key_department', function( $key ) {
    return 'team'; // Use 'team' instead of 'department'
} );

t2/extension/people/post_meta
Modify or add custom post meta fields:

add_filter( 't2/extension/people/post_meta', function( $meta_fields ) {
    $meta_fields['people_linkedin'] = [
        'type'         => 'string',
        'description'  => 'LinkedIn Profile URL',
        'single'       => true,
        'default'      => '',
        'show_in_rest' => true,
    ];
    return $meta_fields;
} );

t2/extension/people/card_inner_blocks
Customize the inner blocks displayed in people cards when using Featured Content:

add_filter( 't2/extension/people/card_inner_blocks', function( $blocks ) {
    // Modify the default blocks structure
    return $blocks;
} );

t2/post_featured_image/fallback (Replaces deprecated filter)
Provide a fallback image for people without featured images:

add_filter( 't2/post_featured_image/fallback', function( $media_fallback, $post_id, $post_type, $site_id ) {
    if ( 'person' === $post_type ) {
        return '<img src="https://example.com/default-avatar.jpg" alt="Default avatar" />';
    }
    return $media_fallback;
}, 10, 4 );

The People extension automatically registers a card template for use with the Featured Content Layout block. The template includes:

link SEO & Sitemap Behavior

The extension integrates with Yoast SEO and WordPress core sitemaps:

When hasSinglePost is false (default):

When hasSinglePost is true:

link Development Tips

  1. Always run build after changes: npm run build compiles both JS and CSS
  2. Meta fields are conditional: Check feature flags before accessing meta fields
  3. Use helper functions: get_post_type_key(), get_taxonomy_role(), get_taxonomy_department()
  4. Test with different configs: Verify behavior with various feature flag combinations

link Common Use Cases

Adding Custom Social Media Fields

// In your theme's functions.php
add_filter( 't2/extension/people/post_meta', function( $meta_fields ) {
    $meta_fields['people_twitter'] = [
        'type'         => 'string',
        'description'  => 'Twitter Handle',
        'single'       => true,
        'show_in_rest' => true,
    ];
    return $meta_fields;
} );

Customizing Archive Queries

add_action( 'pre_get_posts', function( $query ) {
    if ( $query->is_post_type_archive( 'person' ) && $query->is_main_query() ) {
        $query->set( 'orderby', 'title' );
        $query->set( 'order', 'ASC' );
    }
} );

link Dependencies

link Known Limitations