Created
March 9, 2014 06:00
-
-
Save BronsonQuick/9443465 to your computer and use it in GitHub Desktop.
Displaying CMB data example for JohnLion
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 function sz_get_testimonials( $page_id ){ | |
$testimonials = get_post_meta( $page_id, 'testimonial', false ); | |
if ( $testimonials ) { | |
$testimonial_list = "\n<ul>\n"; | |
foreach ( $testimonials as $testimonial ) { | |
$testimonial_image = false; | |
$testimonial_content = false; | |
$testimonial_list .= "\t<li class='row'>"; | |
if ( $testimonial['testimonial-image'] ) { | |
$testimonial_image = wp_get_attachment_image( $testimonial['testimonial-image'], 'full', '', array( 'class' => 'columns small-3' ) ); | |
} | |
if ( $testimonial['testimonial-content'] ) { | |
$testimonial_content .= "<div class='columns small-9'>"; | |
$testimonial_content .= wpautop( $testimonial['testimonial-content'] ); | |
$testimonial_content .= "</div>"; | |
} | |
$testimonial_list .= $testimonial_image; | |
$testimonial_list .= $testimonial_content; | |
$testimonial_list .= "</li>\n"; | |
} | |
$testimonial_list .= "</ul>\n"; | |
return $testimonial_list; | |
} | |
else { | |
return false; | |
} | |
} | |
function sz_the_testimonials( $page_id ) { | |
if ( sz_get_testimonials( $page_id ) ) { | |
echo sz_get_testimonials( $page_id ); | |
} | |
else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks again for sharing this code. I've now used it in my project, extended it to out put more fields and used the method for many more sections of my site. How good are template tags!!! I used them a little a the beginning of the year, I was learning so much at the time that they slipped through. Wow, one line of code in the page template. So nice.