Last active
August 29, 2015 14:07
-
-
Save chrisblakley/78c4a1bee342093dc9eb to your computer and use it in GitHub Desktop.
Various methods of using loops and queries within WordPress
This file contains hidden or 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 query_posts( array( 'category_name' => 'ideas', 'showposts' => 4, 'paged' => get_query_var('paged') ) ); ?> | |
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> | |
<div class="row"> | |
<div class="fourteen columns centered"> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> | |
<div><?php echo nebula_meta('date'); ?></div> | |
<p class="postexcerpt"><?php echo nebula_the_excerpt('Read more »', 30, 1); ?></p> | |
<div<?php echo nebula_meta('tags'); ?></div> | |
</article> | |
</div><!--/columns--> | |
</div><!--/row--> | |
<?php endwhile; ?> | |
<?php wp_pagenavi(); ?> | |
<?php wp_reset_query(); ?> |
This file contains hidden or 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 query_posts('post_type=movie &showposts=6'); ?> | |
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> | |
<h2><?php the_title(); ?></h2> | |
<?php the_content(); ?> | |
<?php endwhile; ?> | |
<?php wp_reset_query(); ?> |
This file contains hidden or 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
<div class="row"> | |
<h4>United States & Canada</h4> | |
<?php $count = 0; ?> | |
<?php query_posts('post_type=wg-distributors &category_name=united-states,canada'); ?> | |
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> | |
<?php if ( $count%2 == 0 && $count != 0 ) : ?> | |
</div><!--/row--> | |
<div class="row"> | |
<?php endif; ?> | |
<div class="eight columns"> | |
<?php if ( the_post_thumbnail() ) : ?> | |
<?php the_post_thumbnail(); ?> | |
<?php endif; ?> | |
<h2><?php the_title(); ?></h2> | |
<?php the_content(); ?> | |
</div><!--/columns--> | |
<?php $count++; ?> | |
<?php endwhile; ?> | |
<?php wp_reset_query(); ?> | |
</div><!--/row--> |
This file contains hidden or 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 if ( have_posts() ) while ( have_posts() ) : the_post(); ?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<h1 class="entry-title"><?php the_title(); ?></h1> | |
<div class="entry-meta"> | |
<hr/> | |
<?php nebula_meta('on', 0); ?> <?php nebula_meta('cat'); ?> <?php nebula_meta('by'); ?> <?php nebula_meta('tags'); ?> | |
<hr/> | |
</div> | |
<div class="entry-content"> | |
<?php the_content(); ?> | |
<?php if ( current_user_can('manage_options') ) : ?> | |
<div class="container entry-manage"> | |
<div class="row"> | |
<hr/> | |
<?php nebula_manage('edit'); ?> <?php nebula_manage('modified'); ?> | |
<hr/> | |
</div> | |
</div> | |
<?php endif; ?> | |
</div><!-- .entry-content --> | |
</article><!-- #post-## --> | |
<?php get_template_part('comments'); | |
<?php endwhile; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment