第一个循环中的代码:
<?php
$terms_as_text = get_the_term_list( $post->ID, 'produktkategori', '', ', ', '' ) ;
echo strip_tags($terms_as_text);
?>
结果为“Spanskt”。我希望在第二个循环中输入“Spanskt”,其中显示“Spanskt”。那可能吗?
提前致谢。
// First loop
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php
$terms_as_text = get_the_term_list( $post->ID, 'produktkategori', '', ', ', '' ) ;
echo strip_tags($terms_as_text);
?> // The value of this...</h1>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
Some content
</article>
<?php endwhile; endif; ?>
// Second loop
<?php $loop = new WP_Query( array( 'post_type' => 'bocker', 'posts_per_page' => 4, 'produktkategori' => 'Spanskt // ...should be entered here', 'orderby' => 'rand', ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
Some content
<?php endwhile; ?>