Below, you’ll find a detailed guide on how to add the Team Showcase Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Team Showcase Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Team Showcase Plugin and the shortcodes it provides:
"Team Showcase is a WordPress plugin that enables you to introduce your team members professionally. With user-friendly interface, you can easily customize team profiles and display styles."
- [team]
- [team_import_xml_layouts]
Team Showcase [team] Shortcode
The Team Showcase shortcode is a powerful tool that displays a specific team member’s information on your WordPress site. By using this shortcode, you can directly call the ‘team_showcase_display’ function, which accepts ‘id’ as a parameter. This ‘id’ refers to the unique identifier of a team member. The function then generates a dynamic HTML block, embedding the team member’s data within a ‘team-container’ div. This allows for flexible and customizable team member displays.
Shortcode: [team]
Parameters
Here is a list of all possible team shortcode parameters and attributes:
id
– Unique identifier of the team showcase
Examples and Usage
Basic example – Showcases a team by referencing its ID
[team id=1 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [team]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'team', array( $this, 'team_showcase_display' ) );
Shortcode PHP function:
function team_showcase_display($atts, $content = null ) {
$atts = shortcode_atts(
array(
'id' => "",
), $atts);
$html = '';
$team_id = isset($atts['id']) ? $atts['id'] : '';
$args = array('team_id'=> $team_id);
ob_start();
?>
<div id="team-<?php echo $team_id; ?>" class="team-container">
<?php
do_action('team_showcase_main', $args);
?>
</div>
<?php
return ob_get_clean();
}
Code file location:
team/team/includes/class-shortcodes.php
Team Showcase [team_import_xml_layouts] Shortcode
The ‘team_import_xml_layouts’ shortcode is a powerful tool that imports XML layouts into your WordPress site. It fetches data from an XML source, creates new posts under ‘team_layout’, and updates post meta.
Shortcode: [team_import_xml_layouts]
Examples and Usage
Basic example – Importing team layouts from an XML source
[team_import_xml_layouts xml_source="http://example.com/path/to/xml"]
Advanced examples
Importing team layouts from a local XML file located within the WordPress installation
[team_import_xml_layouts xml_source="/path/to/local/xml"]
Importing team layouts from an XML source and specifying the user ID for the post author
[team_import_xml_layouts xml_source="http://example.com/path/to/xml" user_id="2"]
Note: The user ID must be a valid user ID of a user in your WordPress installation. If not specified, the function will use the ID of the current user.
Also, please remember that the `team_import_xml_layouts` shortcode should only be used by users with the `manage_options` capability (usually administrators), as it involves creating new posts and updating post metadata.
PHP Function Code
In case you have difficulties debugging what causing issues with [team_import_xml_layouts]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('team_import_xml_layouts', 'team_import_xml_layouts');
Shortcode PHP function:
function team_import_xml_layouts($xml_source)
{
if (!current_user_can('manage_options')) return;
$response = array();
$user_id = get_current_user_id();
$json_obj = file_get_contents($xml_source);
//$xml_json = json_encode($html_obj);
$xml_arr = json_decode($json_obj, true);
$items = $xml_arr['rss']['channel']['item'];
foreach ($items as $item) {
$post_title = isset($item['title']) ? $item['title'] : '';
$postmeta = isset($item['postmeta']) ? $item['postmeta'] : array();
$post_id = wp_insert_post(
array(
'post_title' => $post_title,
'post_content' => '',
'post_status' => 'publish',
'post_type' => 'team_layout',
'post_author' => $user_id,
)
);
// echo '<br>';
// echo $post_title. ' Created';
// echo '<br>';
foreach ($postmeta as $meta) {
$meta_key = isset($meta['meta_key']['__cdata']) ? $meta['meta_key']['__cdata'] : '';
$meta_value = isset($meta['meta_value']['__cdata']) ? $meta['meta_value']['__cdata'] : '';
// echo '<br>';
// //var_dump(unserialize($meta_value));
// echo '<br>';
if ($meta_key == 'layout_options' || $meta_key == 'layout_elements_data' || $meta_key == 'custom_scripts') {
//var_dump($meta_value);
update_post_meta($post_id, $meta_key, unserialize($meta_value));
}
}
}
$response['success'] = __('Import done', 'team');
$team_plugin_info = get_option('team_plugin_info');
if (strpos($xml_source, 'team-pro')) {
$team_plugin_info['import_pro_layouts'] = 'done';
} else {
$team_plugin_info['import_layouts'] = 'done';
}
update_option('team_plugin_info', $team_plugin_info);
}
Code file location:
team/team/includes/functions.php
Conclusion
Now that you’ve learned how to embed the Team Showcase Plugin shortcodes, 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.
Leave a Reply