Skip to content

Instantly share code, notes, and snippets.

@archondigital
Created July 27, 2014 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save archondigital/22150177e484fd9267a8 to your computer and use it in GitHub Desktop.
Save archondigital/22150177e484fd9267a8 to your computer and use it in GitHub Desktop.
WordPress custom taxonomy query and loop
<!-- banner full width home -->
<div id="banner" class="banner-main">
<ul data-orbit data-options="animation:slide;timer_speed:6000;animation_speed:400;stack_on_small:false;navigation_arrows:true;slide_number:false;pause_on_hover:true;resume_on_mouseout:false;bullets:false;timer:true;variable_height:false;">
<?php $args = array( 'banner-location' => 'banner-main-home', 'post_type' => 'govph_banners', 'posts_per_page' => 4, 'orderby' => 'date', 'order' => 'DESC' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li>
<a href="<?php echo get_post_meta($post->ID, "banner-link", $single = true); ?>">
<img class="hide-for-small" src="<?php the_field('banner-artwork-url'); ?>" alt="<?php the_title(); ?>" <?php $bannercaption = get_post_meta($post->ID, 'banner-caption', true); if ($bannercaption) { ?> title="<?php echo get_post_meta($post->ID, "banner-caption", $single = true); ?>"<?php } else { ?><?php } ?> />
<img class="show-for-small" src="<?php the_field('banner-artwork-url-small'); ?>" alt="<?php the_title(); ?>" <?php $bannercaption = get_post_meta($post->ID, 'banner-caption', true); if ($bannercaption) { ?> title="<?php echo get_post_meta($post->ID, "banner-caption", $single = true); ?>"<?php } else { ?><?php } ?> />
</a>
<?php $bannercaption = get_post_meta($post->ID, 'banner-caption', true); if ($bannercaption) { ?>
<div class="orbit-caption"><?php echo get_post_meta($post->ID, "banner-caption", $single = true); ?>
<a href="<?php echo get_post_meta($post->ID, "banner-link", $single = true); ?>">Read more.</a>
</div>
<?php } else { ?>
<?php } ?>
</li>
<?php endwhile; wp_reset_query(); ?>
</ul>
</div>
<!-- banner full width end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment