Team Members Shortcode

Below, you’ll find a detailed guide on how to add the Team Members Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Team Members Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Team Members Plugin and the shortcodes it provides:

Plugin Icon
Team Members

"Team Members is a WordPress plugin designed to help you easily display your team. With its user-friendly interface, showcase your team's profiles, roles, and social media links."

★★★★✩ (50) Active Installs: 30000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [tmm]

Team Members [tmm] Shortcode

The Team Members Manager (TMM) shortcode is used to display a team member’s details. It fetches data like name, job, bio, and social links from the database and displays it in a structured format.

Shortcode: [tmm]

Parameters

Here is a list of all possible tmm shortcode parameters and attributes:

  • name – specifies the name of the team to display

Examples and Usage

Basic example – A simple usage of the shortcode to display a team member’s information by specifying the team name.

[tmm name="marketing"]

Advanced examples

Displaying a team member’s information by specifying the team name and forcing the use of original fonts.

[tmm name="marketing" original_font="yes"]

Displaying a team member’s information by specifying the team name, forcing the use of original fonts, and setting the display order to random.

[tmm name="marketing" original_font="yes" display_order="random"]

Displaying a team member’s information by specifying the team name, forcing the use of original fonts, setting the display order to random, and making the member links open in a new window.

[tmm name="marketing" original_font="yes" display_order="random" piclink_beh="new"]

PHP Function Code

In case you have difficulties debugging what causing issues with [tmm] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("tmm", "tmm_sc");

Shortcode PHP function:

function tmm_sc($atts)
{

  global $post;

  /* Gets table slug (post name). */
  $all_attr = shortcode_atts(array("name" => ''), $atts);
  $name = $all_attr['name'];

  /* Gets the team. */
  $args = array('post_type' => 'tmm', 'name' => $name);
  $custom_posts = get_posts($args);

  $team_view = '';
  foreach ($custom_posts as $post) : setup_postdata($post);

    $members           = get_post_meta(get_the_id(), '_tmm_head', true);
    $tmm_columns       = get_post_meta($post->ID, '_tmm_columns', true);
    $tmm_color         = get_post_meta($post->ID, '_tmm_color', true);
    $tmm_bio_alignment = get_post_meta($post->ID, '_tmm_bio_alignment', true);
    $tmm_display_order = get_post_meta($post->ID, '_tmm_display_order', true);

    /* Shuffle the memebers array if option is set to random, */
    if ($tmm_display_order === 'random')
      shuffle($members);

    /* Checks if member links open in new window. */
    $tmm_piclink_beh = get_post_meta($post->ID, '_tmm_piclink_beh', true);
    ($tmm_piclink_beh == 'new' ? $tmm_plb = 'target="_blank"' : $tmm_plb = '');

    /* Checks if forcing original fonts. */
    $original_font = get_post_meta($post->ID, '_tmm_original_font', true);
    if ($original_font) {
      if ($original_font == "no") {
        $ori_f = 'tmm_theme_f';
      } else if ($original_font == "yes") {
        $ori_f = 'tmm_plugin_f';
      }
    } else {
      $ori_f = 'tmm_plugin_f';
    }

    $team_view .= '<div class="tmm tmm_' . $name . '">';
    $team_view .= '<div class="tmm_' . $tmm_columns . '_columns tmm_wrap ' . $ori_f . '">';

    if (is_array($members) || is_object($members)) {
      foreach ($members as $key => $member) {

        /* Creates Team container. */
        if ($key % 2 == 0) {
          /* Checks if group of two (alignment). */
          $team_view .= '<span class="tmm_two_containers_tablet"></span>';
        }
        if ($key % $tmm_columns == 0) {
          /* Checks if first div of group and closes. */
          if ($key > 0) $team_view .= '</div><span class="tmm_columns_containers_desktop"></span>';
          $team_view .= '<div class="tmm_container">';
        }

        /* START member. */
        $team_view .= '<div class="tmm_member" style="border-top:' . $tmm_color . ' solid 5px;">';

        /* Displays member photo. */
        if (!empty($member['_tmm_photo_url']))
          $team_view .= '<a ' . $tmm_plb . ' href="' . $member['_tmm_photo_url'] . '" title="' . $member['_tmm_firstname'] . ' ' . $member['_tmm_lastname'] . '">';

        if (!empty($member['_tmm_photo']))
          $team_view .= '<div class="tmm_photo tmm_pic_' . $name . '_' . $key . '" style="background: url(' . $member['_tmm_photo'] . '); margin-left: auto; margin-right:auto; background-size:cover !important;"></div>';

        if (!empty($member['_tmm_photo_url']))
          $team_view .= '</a>';

        /* Creates text block. */
        $team_view .= '<div class="tmm_textblock">';

        /* Displays names. */
        $team_view .= '<div class="tmm_names">';
        if (!empty($member['_tmm_firstname']))
          $team_view .= '<span class="tmm_fname">' . $member['_tmm_firstname'] . '</span> ';
        if (!empty($member['_tmm_lastname']))
          $team_view .= '<span class="tmm_lname">' . $member['_tmm_lastname'] . '</span>';
        $team_view .= '</div>';

        /* Displays jobs. */
        if (!empty($member['_tmm_job']))
          $team_view .= '<div class="tmm_job">' . $member['_tmm_job'] . '</div>';

        /* Displays bios. */
        if (!empty($member['_tmm_desc']))
          $team_view .= '<div class="tmm_desc" style="text-align:' . $tmm_bio_alignment . '">' . do_shortcode($member['_tmm_desc']) . '</div>';

        /* Creates social block. */
        $team_view .= '<div class="tmm_scblock">';

        /* Displays social links. */
        for ($i = 1; $i <= 3; $i++) {
          if ($member['_tmm_sc_type' . $i] != 'nada') {
            if ($member['_tmm_sc_type' . $i] == 'email') {
              $team_view .= '<a class="tmm_sociallink" href="mailto:' . (!empty($member['_tmm_sc_url' . $i]) ? $member['_tmm_sc_url' . $i] : '') . '" title="' . (!empty($member['_tmm_sc_title' . $i]) ? $member['_tmm_sc_title' . $i] : '') . '"><img alt="' . (!empty($member['_tmm_sc_title' . $i]) ? $member['_tmm_sc_title' . $i] : '') . '" src="' . plugins_url('img/links/', __FILE__) . $member['_tmm_sc_type' . $i] . '.png"/></a>';
            } else if ($member['_tmm_sc_type' . $i] == 'phone') {
              $team_view .= '<a class="tmm_sociallink" href="tel:' . (!empty($member['_tmm_sc_url' . $i]) ? $member['_tmm_sc_url' . $i] : '') . '" title="' . (!empty($member['_tmm_sc_title' . $i]) ? $member['_tmm_sc_title' . $i] : '') . '"><img alt="' . (!empty($member['_tmm_sc_title' . $i]) ? $member['_tmm_sc_title' . $i] : '') . '" src="' . plugins_url('img/links/', __FILE__) . $member['_tmm_sc_type' . $i] . '.png"/></a>';
            } else {
              $team_view .= '<a target="_blank" class="tmm_sociallink" href="' . (!empty($member['_tmm_sc_url' . $i]) ? $member['_tmm_sc_url' . $i] : '') . '" title="' . (!empty($member['_tmm_sc_title' . $i]) ? $member['_tmm_sc_title' . $i] : '') . '"><img alt="' . (!empty($member['_tmm_sc_title' . $i]) ? $member['_tmm_sc_title' . $i] : '') . '" src="' . plugins_url('img/links/', __FILE__) . $member['_tmm_sc_type' . $i] . '.png"/></a>';
            }
          }
        }

        $team_view .= '</div>'; // Closes social block.
        $team_view .= '</div>'; // Closes text block.
        $team_view .= '</div>'; // END member.

        $page_count = count($members);
        if ($key == $page_count - 1) $team_view .= '<div style="clear:both;"></div>';
      }
    }

    $team_view .= '</div>'; // Closes container.
    $team_view .= '</div>'; // Closes wrap.
    $team_view .= '</div>'; // Closes tmm.

  endforeach;
  wp_reset_postdata();
  return $team_view;
}

Code file location:

team-members/team-members/inc/tmm-shortcode.php

Conclusion

Now that you’ve learned how to embed the Team Members Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *