How to define a taxonomy term to list of pages within a term (3 posts)

  1. NoArtworkAvailable
    Posted 2 years ago #

    Hi there,

    I've been working on trying to create a listing of pages within a taxonomy term and for the most part I've been able to get it working when I hard code the term in my wp query. Ideally what I'd like it to do is change to display the appropriate list when on a page with a different taxonomy term.

    How can I make it so that it will pick the current taxonomy term and stick it within my new wp query?

        $query = new WP_Query( array( 'artist' => 'HARDCODEDTERM', 'post_type' => 'page' ) );?>
            <?php while ( $query->have_posts() ) : $query->the_post();?>
            <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
        <?php endwhile;?>
  2. curlybracket
    Posted 2 years ago #

    try this :

    $current = get_term_by( 'slug', get_query_var('term'), 'artist' );
  3. NoArtworkAvailable
    Posted 2 years ago #

    Where would I stick $current in the query? When I change 'artist' => 'HARDCODEDTERM' to 'artist' => '$current' or to 'artist' => $current, it doesn't load the template anymore. Any suggestions?

Topic Closed

This topic has been closed to new replies.

About this Topic