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
votes
1 Answers
0
votes
Try this:
$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 .= '>';
Havent tested it, but it should work