I'm looking for a way to create "player-objects" that are then all displayed on one page. They should just contain a few text-datafields with the players name, role and an image. Since I'm very new to wordpress, I have trouble finding anything that fits what I need. The plan is to list the players on a "roster"-page for the specific game they play, so a "game"-category would be helpful for sorting them.

Edit: I have trouble describing what exactly I'm searching for, I will provide further info if needed

1 Answer 1


For players you could create a custom post type, like so

function my_player_cpt() {
  $labels = array(
    'name'                  => _x( 'Players', 'Post type general name', 'textdomain' ),
    'singular_name'         => _x( 'Player', 'Post type singular name', 'textdomain' ),
  $args = array(
    'labels'             => $labels,
    'public'             => true,
    'taxonomies'         => array('game')
    'supports'           => array( 
      'title', // player name
      'thumbnail', // player image
      'excerpt' // player role
  register_post_type( 'player', $args );
add_action('init', 'my_player_cpt');

The excerpt field could be used to save the player role. Other option could be a custom meta field.

And games could probably be custom taxonomy,

function my_game_taxonomy() {
  $args = array(
    'label'        => __( 'Game', 'textdomain' ),
    'public'       => true,
  register_taxonomy( 'game', 'player', $args );
add_action('init', 'my_game_taxonomy');

To have the post type and taxonomy theme independent you should put the above code into a custom plugin. That way the content stays visible in the WP admin even if you ever change your theme.

Then in your theme directory create a taxonomy-game.php template and add your roster page code to it. Simple loop example below.

// taxonomy-game.php

if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>
    <article class="player">
        <?php the_post_thumbnail( 'thumbnail' ); ?>

      <h2><?php the_title(); ?></h2>

      <span><?php the_excerpt(); ?></span>
    <?php endwhile; ?>

        <?php // Navigation ?>

    <?php else : ?>

        <?php // No Posts Found ?>


  • 1
    Looks like I forgot to leave a comment! This is exactly what I needed, sorry for the late response & thank you very much :) Commented Jul 11, 2020 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.