Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to manually display the link of a custom taxonomy term that I have created. The taxonomy is 'event-themes' and the term is 'Boat'. Here's my code:

<?php $themeOne = array(
            'tax_query' => array(
                array(
                    'taxonomy' => 'event-themes',
                    'field' => 'slug',
                    'terms' => 'boat-theme'
                )
            )
        );
        ?>
        <li><a href=""><img src="<?php bloginfo('template_directory'); ?>/images/eventSearch/theme-onFoot.png" /><span><?php echo $themeOne; ?></span></a></li>

I'm not very familiar with PHP so I guess I'm probably missing something very obvious here, but my main aim is to simply 'handpick' the taxonomy term I want, and display a link to the page displaying all posts/pages under it.

Thanks

share|improve this question
add comment

2 Answers 2

In your code you are just storing an "array" in the variable $themeOne. The code you should be using to make the query is:

$themeOne = new WP_Query(array(
'tax_query' => array(
    array(
        'taxonomy' => 'event-themes',
        'terms' => 'boat-theme'
    )
)
));

The result should be an array of objects. You can then access these using the following code:

foreach($themeOne as $term){
    print $term->slug;
}
share|improve this answer
add comment

You are mixing functions. The tax query array is intented to modify the query that affect the loop. To just manually print the term link you can do:

<li><a href=""><img src="<?php bloginfo('template_directory'); ?>/images/eventSearch/theme-onFoot.png" /><span><?php echo get_bloginfo('url').'/event-themes/boat-theme'; ?></span></a></li>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.