• noartworkavailable

    (@noartworkavailable)


    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?

    <?php
        $query = new WP_Query( array( 'artist' => 'HARDCODEDTERM', 'post_type' => 'page' ) );?>
            <ul>
    
            <?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;?>
    
           </ul>
Viewing 2 replies - 1 through 2 (of 2 total)
  • try this :

    $current = get_term_by( 'slug', get_query_var('term'), 'artist' );

    Thread Starter noartworkavailable

    (@noartworkavailable)

    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to define a taxonomy term to list of pages within a term’ is closed to new replies.