Php 使用thumbnai图像中的锚定标记重定向到wordpress中的类别页面
我使用了一个logo滑块并调用了Php 使用thumbnai图像中的锚定标记重定向到wordpress中的类别页面,php,wordpress,Php,Wordpress,我使用了一个logo滑块并调用了theu post\u thumbnai()函数来显示图像。缩略图来自不同的类别。现在,当我保留anchor标记并使用permalink时,它会在single.php页面中链接到我。 我想重定向到具有相同类别的产品页面的链接。 我使用了以下代码 <?php $categories=get_the_category(); $output=''; if($categories){ foreach ($categories as $category ) { $
theu post\u thumbnai()
函数来显示图像。缩略图来自不同的类别。现在,当我保留anchor标记并使用permalink时,它会在single.php
页面中链接到我。
我想重定向到具有相同类别的产品页面的链接。
我使用了以下代码
<?php
$categories=get_the_category();
$output='';
if($categories){
foreach ($categories as $category ) {
$output.='<a href="'.get_category_link($category->term_id).'?slug='.$category->slug.'">'
.$category->cat_name.'</a>';
}
echo $output;
}?>
<?php
$categories=get_the_category();
$output='';
if($categories){
foreach ($categories as $category ) {
$args = array(
'category' => $category->term_id ,
'post_type' => 'post',
'post_status' => 'publish',
);
$posts_array = get_posts( $args );
foreach ( $posts_array as $post ) :
setup_postdata( $post );
$output.='<a href="'.get_permalink();.'">'
.$category->cat_name.'</a>';
endforeach;
wp_reset_postdata();
}
echo $output;
}?>