Skip to content

Instantly share code, notes, and snippets.

@yaulaannl
Created December 19, 2016 08:02
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 yaulaannl/f45a905513441f9f2af77aecab0a4fd4 to your computer and use it in GitHub Desktop.
Save yaulaannl/f45a905513441f9f2af77aecab0a4fd4 to your computer and use it in GitHub Desktop.
Wordpress custom post query example
<?php $loop = new WP_Query( array( 'post_type' => 'tutorial', 'orderby' => 'post_id', 'order' => 'DSC','posts_per_page' => -1 ) ); ?>
<?php if ( $loop->have_posts() ) : ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="row tutorial-list">
<a href="<?php echo esc_url(get_permalink()); ?>" >
<span class="link-spanner"></span>
</a>
<div class="col-sm-3">
<h4><?php the_field('type'); ?></h4>
</div>
<div class="col-sm-6">
<h4><?php the_field('list_title'); ?></h4>
</div>
<div class="col-sm-3">
<h4><?php the_field('lesson_number'); ?> Lessons</h4>
</div><!-- column 4-->
</div> <!-- row -->
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment