Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Jeez, once you figure out that each item of a custom taxonomy is called a term (not immediately obvious in the wordpress docs for the noob), its all much simpler to search for. This solution is easier to understand without all the custom query stuff.</p> <pre><code>&lt;?php // A term is an item of a taxonomy (e.g. "Promotional" could be a term for the taxonomy "video_type") // ...so $categories could be $terms and it would still make sense $categories = get_terms('taxonomy_name'); foreach( $categories as $category ): ?&gt; &lt;section class="category-&lt;?php echo $category ?&gt;"&gt; &lt;h2&gt;&lt;?php echo $category-&gt;name; // Print the cat title ?&gt;&lt;/h2&gt; &lt;p class="description"&gt;&lt;?php echo $category-&gt;description ?&gt;&lt;/p&gt; &lt;div class="&lt;?php echo $category-&gt;post_type ?&gt;-list"&gt; &lt;?php //select posts in this category (term), and of a specified content type (post type) $posts = get_posts(array( 'post_type' =&gt; 'custom_post_type_name', 'taxonomy' =&gt; $category-&gt;taxonomy, 'term' =&gt; $category-&gt;slug, 'nopaging' =&gt; true, // to show all posts in this category, could also use 'numberposts' =&gt; -1 instead )); foreach($posts as $post): // begin cycle through posts of this category setup_postdata($post); //set up post data for use in the loop (enables the_title(), etc without specifying a post ID) ?&gt; // Now you can do things with the post and display it, like so &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt; &lt;h3&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt; &lt;?php // Getting custom field data example echo get_post_meta($post-&gt;ID, 'field_key', true); ?&gt; &lt;?php the_content() ?&gt; &lt;/article&gt; &lt;?php endforeach; ?&gt; &lt;/div&gt; &lt;/section&gt; &lt;?php endforeach; ?&gt; </code></pre> <p>And then any gaps in understanding can be filled by searching the functions above in the wordpress codex. In the above code, for my specific application, custom_post_type_name would be video, and taxonomy_name would be video_type (or video_types, I forget).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload