Working With “The Loop”

The Loop” is A WordPress term that refers to the process of displaying posts. The Loop processes each of the posts to be displayed on the current page and formats them according to how they match specified criteria within The Loop template tags.

Using query_posts() and/or WP_Query allows to you to alter The Loop query to display the exact posts you’re looking for, including taxonomy queries to display posts “tagged” by a certain taxonomy.

As of version 1.0.2, CPT-onomies works with taxonomy queries within The Loop.

FYI: If using the tax query, and querying by ID, a CPT-onomy term’s term ID is the same as it’s post ID.

Display ‘movies’ that include ‘Tom Hanks’ from the ‘actors’ CPT-onomy:


$args = array(
   'post_type' => 'movies',
   'tax_query' => array (
      array (
         'taxonomy' => 'actors',
         'field' => 'slug',
         'terms' => 'tom-hanks',
         'operator' => 'IN'
if ( have_posts() ) : ?>
   <?php while ( have_posts() ) : the_post(); ?>
      <li><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
   <?php endwhile; ?>
<?php endif;


Related Functions

WordPress Codex

For more information, refer to the WordPress codex.


  • web559 says:

    This is unrelated to the plugin itself, but in the code example you are meant to use the_title_attribute() instead of the_title() when setting an HTML attribute. Some title filters contain HTML tags, and then you get tags inside of tags.

  • KJ says:

    thanks for the awesome plugin, solved my problem quick and easy…do you offer a premium version? why not get paid for your work?

Leave a Reply