Posts by Taxonomy Term

Now that I’ve got the display of all sermons and the pagination sorted, it’s time to figure out how to display just the sermons from a particular speakers.

The get_the_term_list() function returns a link which should arrive at a page showing all sermons by that speaker, but for it to work, some extra work is needed.

Adding Taxonomy Template

Create a new file named taxonomy-speaker.php. This can be copied from tag.php in the twenty ten parent theme. The template hierarchy will load this file when getting sermons from a specific speaker.

Code Changes

Add the following line before the printing of the page title.

$term = get_term_by('slug',get_query_var('term'),get_query_var('taxonomy'));

Modify the bit in between the <span> tags to $term->name.

Change the get_template_part() function to get_template_part('loop','sermons') to use the customized loop for sermons. This will ensure that the speaker name and full text are displayed.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s