Posted By

zealmurapa on 04/22/11


Tagged

post type query any anywhere


Versions (?)

Query any Post Type anywhere


 / Published in: PHP
 

Query any Post Type anywhere

  1. //when 'blog' is the custom post type
  2. <?php $args = array( 'post_type' => 'blog', 'posts_per_page' => 1);
  3. $loop = new WP_Query( $args ); ?>
  4. <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  5. <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  6. <?php endwhile; ?>

Report this snippet  

You need to login to post a comment.