Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 作为链接的回显类别名称_Php_Variables - Fatal编程技术网

Php 作为链接的回显类别名称

Php 作为链接的回显类别名称,php,variables,Php,Variables,我有以下代码,而不是“阅读更多”链接,我希望它显示的类别名称作为链接。有人知道我怎样才能做到这一点吗 $the_cat = get_the_category($post->ID); $category_name = $the_cat[0]->cat_name; $category_link = get_category_link( $the_cat[0]->cat_ID ); $slider_gallery.= '<br/><s

我有以下代码,而不是“阅读更多”链接,我希望它显示的类别名称作为链接。有人知道我怎样才能做到这一点吗

    $the_cat = get_the_category($post->ID);
    $category_name = $the_cat[0]->cat_name;
    $category_link = get_category_link( $the_cat[0]->cat_ID );
    $slider_gallery.= '<br/><span class="chpcs_more"><a href="'.$category_link.'">read more</a></span>';
$the_cat=获取_类别($post->ID);
$category_name=$the_cat[0]->cat_name;
$category\u link=get\u category\u link($cat[0]->cat\u ID);
$slider_gallery.='
';
谢谢你试试这个

$slider_gallery.= '<br/><span class="chpcs_more"><a href="'.$category_link.'">'.$category_name.'</a></span>';
$slider_gallery.='
';
只需执行与使用类别链接相同的操作,如下所示:

$the_cat = get_the_category($post->ID);
$category_name = $the_cat[0]->cat_name;
$category_link = get_category_link( $the_cat[0]->cat_ID );
$slider_gallery.= '<br/><span class="chpcs_more"><a href="'.$category_link.'">'.$category_name.'</a></span>';
$the_cat=获取_类别($post->ID);
$category_name=$the_cat[0]->cat_name;
$category\u link=get\u category\u link($cat[0]->cat\u ID);
$slider_gallery.='
';
您正在使用wordpress,是吗?