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

藏色散人
藏色散人Original
2019-12-25 10:54:492778browse

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( &#39;分类名称&#39;); 
$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(&#39;分类名称&#39;); //获取分类名称的分类数据 
$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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn