WordPress.org

Ready to get started?Download WordPress

Forums

Query to display data from cutom post type (2 posts)

  1. Preserved
    Member
    Posted 2 years ago #

    I'm very new to WordPress so I may have my terms mixed up. I've registered a custom post type called exhibitors. Within that CPT I have many taxomonies set up (categories).

    I have custom template to display the CPT and I'm stuck on the query. So far, I can get all the exhibitors and display them.

    new WP_Query( array( 'post_type' => 'exhibitors', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => 20 ) );

    How do I get at the taxomonies? What I'm looking for is something like this:
    EXHIBITORS:

    Bakers
    -joes bakery
    -sallys cupcakes

    Flower Shops
    -jims roses
    -peters pedals

    To display I'm using a loop in Geneses:

    function exhibitor_loop() {

    $loop = new WP_Query( array( 'post_type' => 'exhibitors', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => 20 ) ); ?>

    <div id="allexhibitors">

    <h1><?php the_title(); ?></h1>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    " ><?php the_title(); ?></br>

    <?php endwhile;?>
    </div><!--end #exhibitors -->
    <?php
    }

  2. stvwlf
    Member
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.