This question already exists: Php string not working in Wordpress Functions.php (trying to fetch 1st category for each blog that post appears in the sidebar) Closed 3 years ago.admin管理员组文章数量:1291491
How to pass the following code.
<div> <?php $category = get_the_category(); ?>
<a href="<?php echo get_category_link($category[0]->cat_ID); ?> ">
<?php echo $category[0]->cat_name; ?> </a>
</div>
In the function.php file's following code.
$related_blog .="//want to pass the above code here.";
For detailed description visit here: click here
This question already exists: Php string not working in Wordpress Functions.php (trying to fetch 1st category for each blog that post appears in the sidebar) Closed 3 years ago.How to pass the following code.
<div> <?php $category = get_the_category(); ?>
<a href="<?php echo get_category_link($category[0]->cat_ID); ?> ">
<?php echo $category[0]->cat_name; ?> </a>
</div>
In the function.php file's following code.
$related_blog .="//want to pass the above code here.";
For detailed description visit here: click here
Share Improve this question asked May 28, 2021 at 12:19 rt5277rt5277 12 bronze badges 1- If your question does not get much attention, you should improve it by editing it so that it's clearer and easier to understand, do not repost it as a new duplicate question – Tom J Nowell ♦ Commented May 28, 2021 at 13:02
1 Answer
Reset to default 0You can use below code to append the string:
<?php
$category = get_the_category();
$related_blog .= '<div><a href="'. get_category_link($category[0]->cat_ID). '">'. $category[0]->cat_name.' </a></div>';
?>
本文标签: Php string not working in Wordpress Functionsphp
版权声明:本文标题:Php string not working in Wordpress Functions.php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741533188a2383878.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论