• Resolved miguel84

    (@miguel84)


    I have

    $args = array( 'numberposts' => '15' );
    $recent_posts = wp_get_recent_posts( $args );
    foreach( $recent_posts as $recent ){
    $country = strip_tags( get_the_term_list( $recent->ID, 'location', '', ', ', '' ) );
    
    etc other code

    and the country variable is assigned the country taxonomy of 1st post queried, and doesn’t refresh for the remaining posts…. any idea why?

    cheers

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try changing this:

    $country = strip_tags( get_the_term_list( $recent->ID, 'location', '', ', ', '' ) );

    …to this:

    $country = strip_tags( get_the_term_list( $recent['ID'], 'location', '', ', ', '' ) );

    That is untested, but at first glance I’m pretty sure your $recent variable is an array of arrays, not an object.

    Thread Starter miguel84

    (@miguel84)

    Yes my friend, it works now. Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘strip_tags inside loop keep the 1st value assigned and doesn't update’ is closed to new replies.