Forums

Most efficient way of looping through custom taxonomies (2 posts)

  1. travistingey
    Member
    Posted 1 year ago #

    These forums have been such a great help, I thought I might as well jump in and ask my own question. I'm using WP custom post type and taxonomies to create a custom theme to make WordPress act as the CMS for my personal site. I've been teaching myself PHP and the WordPress codex over the years so I want to make sure I get it right.

    I have a custom post type "Portfolio" with a hierarchical taxonomy "Project Type" registered to it. I want to list posts by their project type. Currently I'm running three seperate loops to display links for each project type (Web, Print, Illustration) Example one WP_Query is:

    <?php $thequery = new WP_Query('post_type=portfolio&posts_per_page=-1&project_type=web'); ?>
    --- Do some loop stuff ---

    end result looks something like this:

    <h2>Web</h2>
    <ul>
            <li><a>Project 1</a></li>....
    </ul>
    
    <h2>Print</h2>
    <ul>
            <li><a>Project 1</a></li>....
    </ul>
    ... etc

    Is it inefficient to have a loop per project type is there a way to have only one query for a custom post type and use conditionals in the loop to organize by project type? I've been searching the codex and forums and can't seem to find a solution. Thanks in advance!

  2. jloft
    Member
    Posted 1 year ago #

    I think this is a similar question to what I'm asking in this newer forum entry:

    http://wordpress.org/support/topic/custom-taxonomy-related-posts

    Can anyone help us out? We need help figuring out how to code the same functions we typically do with the default post type and taxonomies but with our custom post types and custom taxonomies.

Topic Closed

This topic has been closed to new replies.

About this Topic