admin管理员组文章数量:1292298
I am trying to fetch 1st category for each blog post that appears in the sidebar of any blogpost landing page.
I tried multiple options to add the 2nd block code to the 1st block at the line ".wp_get_post_categories ($post_id)."
but I could not find any solution.
Please help me with that and if you need closer to the code just let me know.
1st Block
$related_blog .="<div class='related-blog'>
<div class='row'>
<a href=".get_the_permalink().">
<div class='col-lg-4 col-md-4 col-xs-4 blog-image'>
<img src=".$image_related[0].">
</div>
<div class='col-lg-8 col-md-8 col-xs-8 blog-text'>
<strong><p class='related-blog-title'>".get_the_title()."</p></strong>
</a>
<span class='related-blog-sidebar-content '>".substr(get_the_content(),0,250)."...</span>
<p class='related-blog-sidebar-category'>
".wp_get_post_categories ($post_id)."
</p>
<a class='related-blog-sidebar-link' href=".get_the_permalink().">Read More
</a>
</div>
</div>
</div>";
2nd Block
<?php $category = get_the_category(); ?>
<a href="<?php echo get_category_link($category[0]->cat_ID); ?> ">
<?php echo $category[0]->cat_name; ?> </a>
本文标签:
版权声明:本文标题:categories - Php string not working in Wordpress Functions.php (trying to fetch 1st category for each blog that post appears in 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741533114a2383873.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论