I’m attempting to build a glossary by using a custom post type for each glossary entry and a custom field to define what letter it should be grouped under.
I have a template that will list all the posts in the glossary so now I need to create a compound statement to display only custom posts with a selected letter – the resulting display being, for example, all the entries under A.
I’m new to WP and have almost no experience with php so as I work through the codex trying to find the appropriate way to create the compound query/filter, I seem to be making little progress at finding what I want.
My question is a little vague, but what I want are perhaps some pointers as to how to tackle this requirement so that I can focus on the appropriate parts of the codex and learn what I need.
The template for listing all the glossary entries is as follows:
<?php /* Template Name: Glossary List */ ?> <?php get_header(); ?> <div class="glossarybody"> <h2>Glossary</h2> <p class="glossarybodytext">This is the glossary section of the library. Glossary Terms are listed below. Click on the word or phrase of interest to see more information. </p> </div> <?php $loop = new WP_Query( array( 'post_type' => 'glossary', 'posts_per_page' => 10 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <div> <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> </div> <?php endwhile; ?> <?php get_sidebar(); ?> <?php get_footer(); ?>
is this going to be a case of simply altering this piece of code or is this a more complex requirement?
I realize there are some plugins that create glossaries but none of them appear to give the results that I want.
- The topic ‘building a query of a custom post type and custom field.’ is closed to new replies.