我想在函数中添加WordPress循环。我尝试在功能中添加此代码,但它无法正常工作。使用global $post;
也不会产生任何影响。谁能告诉我如何在函数中添加循环?
循环:
$term_lists = wp_get_post_terms($post->ID, 'vendors', array("fields" => "all"));
foreach($term_lists as $term_singles) {
echo $custotaxos = $term_singles->slug."<br>"; //do something here
$myposts = get_posts(array(
'showposts' => -1,
'post_type' => 'vendor',
'tax_query' => array(
array(
'taxonomy' => 'vendors',
'field' => 'slug',
'terms' => array($term_singles->name))
))
);
foreach ($myposts as $mypost) {
echo $mypost->post_title . '<br/>';
echo $mypost->ID . '<br/>';
echo get_permalink($mypost->ID);
echo "<br>";
}
}
功能:
function woo_custom_product_tab_content() {
}
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tab' );