代码一、通过分类别名获取Wordpress分类链接:
<?php
$cat=get_category_by_slug('wordpress');
$cat_links=get_category_link($cat->term_id);
?>
<a href="<?php echo $cat_links; ?>" title="<?php echo $cat->name; ?>">更多</a>代码二、通过分类ID获取Wordpress分类链接:
<?php
$cat=get_term_by('id', 12, 'category');
$cat_links=get_category_link($cat->term_id);
?>
<a href="<?php echo $cat_links; ?>" title="<?php echo $cat->name; ?>">更多</a>当前链接的数据库用法
global $wp; $current_url = home_url(add_query_arg(array(),$wp->request)); echo $current_url;
普通用法
the_permalink();
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号