Skip to content

Instantly share code, notes, and snippets.

@chyngyz
Created November 28, 2016 18:02
Show Gist options
  • Save chyngyz/ebc7f9c02181a9cd717761a38bc366d6 to your computer and use it in GitHub Desktop.
Save chyngyz/ebc7f9c02181a9cd717761a38bc366d6 to your computer and use it in GitHub Desktop.
Wordpress Query by category slug
<?php
$args = array(
'category_name' => 'slider'
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) : ?>
<div id="vgslider" class="vg__slider-wrap owl-carousel owl-theme">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php if(has_post_thumbnail()) :?>
<div class="vg__slider vg__slider--1" style="background-image:url('<?php the_post_thumbnail_url( 'full' ); ?>')">
<?php if( rwmb_meta( 'vg_url' ) ) :?>
<a href="<?php echo rwmb_meta( 'vg_url' ); ?>" class="vg__slider__more-btn">
<?php echo rwmb_meta( 'vg_readmore' ); ?>
</a>
<?php endif; ?>
</div>
<?php else :?>
<?php endif;?>
<?php endwhile; ?>
</div><!-- #video-sidebar-right -->
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment