post - Wordpress loop how to get tag slug and be value in query_posts -


what trying is:

  • among posts in category 1 every post has tag
  • now in post under category want call posts category 1 have same tag example cat=1&tag=1 , cat=2&tag=1

here code , it's not working:

<?php              $t = wp_get_post_tags($post->id);                           query_posts( 'cat=45&tag=' . $t. '' );                                         // loop      while ( have_posts() ) : the_post(); ?> 

you have pass tag id in query_posts , wp_get_post_tags() returns array not id best achieve posts tag have pass tag-id

<?php       $t = wp_get_post_tags($post->id);       query_posts( 'cat=45&tag=' . $t[0]->term_id. '' );                                         // loop      while ( have_posts() ) : the_post(); ?> 

there can multiple tags have loop through $t tag ids

please refer manual wp_get_post_tags


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -