Home > Article > CMS Tutorial > How to get the link address of a certain column in wordpress
#How to get the link address of a certain column in wordpress?
wordpress There are two ways to obtain the link address of a certain category. This article will introduce it in detail. Friends who need to know more can refer to the following
recommendation: "wordpress Tutorial》
Two methods for wordpress to obtain the link address of a certain category:
Get the link URL of the category article through get_category_link(), The parameter is the ID of the article (method to obtain article ID)
The first php example is as follows:
The code is as follows:
<?php $category_id = get_cat_ID( '分类名称'); $category_link = get_category_link( $category_id ); ?> <a href=”<?php echo $category_link; ?>” title=”Category Name”> 分类名称 </a>
The second php example is as follows:
The code is as follows:
<?php$cat=get_category_by_slug('分类名称'); //获取分类名称的分类数据 $cat_links=get_category_link($cat->term_id); // 通过$cat数组里面的分类id获取分类链接 ?> <a href="<?php echo $cat_links; ?>" title="<?php echo $cat->name; ?>"><?php echo $cat->name; ?></a>
For more WordPress related technical articles, please visit the WordPress tutorial column: https://www.php.cn/cms/wordpress/
The above is the detailed content of How to get the link address of a certain column in wordpress. For more information, please follow other related articles on the PHP Chinese website!