Created
April 14, 2015 14:00
-
-
Save Mamaduka/e7725a9b789c2386a676 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Handle Team shortcode. | |
* | |
* @param array $attr Array of shortcode attributes. | |
* @return string $output HTML | |
*/ | |
function maintainn_team_shortcode( $attr = array() ) { | |
// Get post object. | |
$post = get_post(); | |
// Get team members attached to this page. | |
$members = get_post_meta( $post->ID, '_maintainn_team_meta', true ); | |
$output = ''; | |
// Return empty string, if we don't have members. | |
if ( empty( $members ) ) { | |
return $output; | |
} | |
// We have team members and now we can output them. | |
$output .= '<ul class="maintainn-team">'; | |
foreach ( $members as $member ) { | |
$output .= '<li class="member">'; | |
$output .= '<img src="' . esc_attr( $member['photo'] ) . '" alt="' . esc_attr( $member['fullname'] ) . '" />'; | |
$output .= '<h3 class="fullname">' . esc_attr( $member['fullname'] ) . '</h3>'; | |
$output .= '<p class="position">' . esc_attr( $member['position'] ) . '</p>'; | |
$output .= '</li>'; | |
} | |
$output .= '</ul>'; | |
return $output; | |
} | |
add_shortcode( 'maintainn_team', 'maintainn_team_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excuse me if I comment this code, but I'm a bit perplexed.
I create a group field (here) that it seems similar to your group and so I used your code with my fields in order to create a shortcode (here) but it don't works, and I don't understand why the shortcode didn't print the field values!?
Any suggestions, please?