WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I feel like I'm this close but can't figure out if it's a synax or variable thing. I'm tring to echo the slug to auto-populate the corresponding image.


    $terms = get_the_terms( $post->id, 'series', array( 'parent' => 0 ) ); 
    $terms_slugs = array();
    foreach( $terms as $term ) {
        $terms_slugs[] = $term->slug; 

    if( !empty($terms_slugs) ) :
      echo "/assets/products/" . $terms_slugs. "/logos/" .$terms_slugs . "-logo.png" ;
share|improve this question
up vote 2 down vote accepted

Here's the correct syntax for what you're trying to do, if there's just the single value for the 'series' custom taxonomy slug that you're trying to retrieve. You were passing the whole array to your echoed string. I made a new variable $series which pulls the first/only value in the $terms_slugs array. And simplified a few other things you didn't need in there. :)

    $terms = get_the_terms( $post->ID, 'series' );
    if ($terms) {
        $terms_slugs = array();
        foreach ( $terms as $term ) {
            $terms_slugs[] = $term->slug;
        $series = $terms_slugs[0];      
        echo "/assets/products/{$series}/logos/{$series}-logo.png";
    } else {
        echo "nothing to see here";
share|improve this answer
I <3 you Sky!!! – kristina childs Aug 2 '13 at 5:26

Your Answer


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.