Created
February 17, 2014 23:33
-
-
Save bahia0019/9061477 to your computer and use it in GitHub Desktop.
This file contains 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 | |
add_filter('the_content', 'fyc_the_content'); | |
function fyc_the_content( $content ) { | |
if (is_singular( 'clients' ) && in_the_loop()) { | |
ob_start(); ?> | |
<div class="fyc-top"> | |
<div class="fyc-client-featured"> | |
<?php the_post_thumbnail('large'); ?> | |
</div> <!-- Close .fyc-client-featured --> | |
<div class="fyc-client-sidebar"> | |
<div> | |
<?php | |
// The query variable | |
$queried_term = get_query_var( 'Clients' ); | |
// Return the terms for current post based off the query variable. Make you sanitize your queries!! | |
$terms = wp_get_post_terms( absint( get_the_ID() ), sanitize_title( $queried_term ), array( 'fields' => 'all' ) ); | |
// Start the arguments for WP_Query(). We'll define an empty tax_query | |
// so we hav something to dump our terms into programatically. | |
$args = array( | |
'post_type' => 'post', | |
'tax_query' => array() | |
); | |
// Loop through all the terms returned for the post and add them to | |
// the tax_query in the proper format | |
foreach ( $terms as $term ) { | |
$args['tax_query'][] = array( | |
'taxonomy' => sanitize_title( $queried_term ), | |
'field' => 'slug', | |
'terms' => sanitize_title( $term->slug ) | |
); | |
} | |
// Fetch the posts we need | |
$client_posts = new WP_Query( $args ); | |
// Start the loop | |
if ( $client_posts->have_posts() ) : while ( $client_posts->have_posts() ) : $client_posts->the_post(); | |
echo get_the_title(); | |
endwhile; | |
else : | |
// Handle the loop when no posts exist | |
endif; | |
// FIN | |
wp_reset_postdata(); | |
?> | |
</div> | |
<p> <?php the_field('client_proofing_url'); ?></p> | |
</div> <!-- Close .fyc-client-sidebar --> | |
</div> <!-- Close .fyc-top --> | |
<div class="fyc-midriff"> | |
<div class="fyc-client-story"> | |
<h3>Love Story</h3> | |
<p><?php the_field('client_story'); ?></p> | |
</div> | |
<div class="fyc-client-review"> | |
<h3>Reviews</h3> | |
<p><?php the_field('client_review'); ?></p> | |
</div> | |
</div> <!-- Close .fyc-midriff --> | |
<?php | |
echo ob_get_clean(); | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment