Skip to content

Instantly share code, notes, and snippets.

@theukedge
Created February 25, 2014 16:02
Show Gist options
  • Save theukedge/9211834 to your computer and use it in GitHub Desktop.
Save theukedge/9211834 to your computer and use it in GitHub Desktop.
<?php // SPECIAL FEATURE CONTENT SHORTCODE
function hpc_special_feature_shortcode( $atts ) {
extract( shortcode_atts(
array(
'type' => '',
'showposts' => -1,
'feature' => '',
'cat' => '',
'offset' => '',
'layout' => 'bullets'
), $atts )
);
$hpc_special_feature_query = new WP_Query( array(
'post_type' => $type,
'showposts' => $showposts,
'tax_query' => array(
array(
'taxonomy' => 'special-feature',
'field' => 'slug',
'terms' => $feature
)
),
'category_name' => $cat,
'offset' => $offset
) );
ob_start(); ?>
<div class="<?php echo $feature; ?>-content <?php echo $type; ?> <?php echo $layout; ?>">
<?php if( $layout == 'bullets' ) { ?>
// BULLETS LOOP - NOT IMPORTANT FOR EXAMPLE
<?php } elseif( $layout == 'small-feature' ) { ?>
// SMALL FEATURE LOOP - NOT IMPORTANT FOR EXAMPLE
<?php } elseif( $layout == 'big-feature' ) { ?>
// BIG FEATURE LOOP - NOT IMPORTANT FOR EXAMPLE
<?php } elseif( $layout == 'small-excerpt' ) { ?>
// SMALL EXCERPT LOOP - NOT IMPORTANT FOR EXAMPLE
<?php } ?>
</div>
<?php $output = ob_get_contents();
ob_end_clean();
return $output;
wp_reset_postdata();
}
add_shortcode( 'special-feature-content', 'hpc_special_feature_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment