2013-03-07 85 views
0
i have a line in visual composer for wordpress which is as follows 

$teasers .= '<li class="xyz">'; 

there is another piece of code : 


foreach ((array) get_object_taxonomies($post->post_type) as $taxonomy) { 
    $object_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'all')); 
    if ($object_terms) { 
    echo 'data-'. $taxonomy.'="'; 
    foreach ($object_terms as $term) 
    { 
     echo $term->name.' , ';   
    } 

    echo '" '; 
    } 
} 

this code results some thing like this 

data-minimum_qualification="10+2 , " data-stream="Commerce , Humanities (Arts) , " data-minimum_qualification="Graduate , Graduate+ , " 


Now what i want is, the result of second code to append inside the first code i.e. in the li tags which would result the following 

<li class="xyz" data-minimum_qualification="10+2 " data-stream="Commerce , Humanities (Arts)" data-minimum_qualification="Graduate , Graduate+" > 

Any kind of help would be great 

回答

0

試試這個:

$teasers .= '<li class="xyz" '; 

foreach ((array) get_object_taxonomies($post->post_type) as $taxonomy) { 
    $object_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'all')); 
    if ($object_terms) { 
    $teasers .= 'data-'. $taxonomy.'="'; 
    foreach ($object_terms as $term) 
    { 
     $teasers .= $term->name.' , ';   
    } 

    echo '" '; 
    } 
} 
$teasers .= '>'; 

還沒有測試它,但它應該工作