php - 仅获取 slug 自定义分类的可变部分
问题描述
在我的主页上,我编写了一个查询来显示分类中的所有元素 (jobpost_job_type) 我想将它们链接到存档页面,但调整搜索的 url 以便显示正确的结果。
$args = array(
'hide_empty' => false
);
$taxonomy = 'jobpost_job_type';
$terms = get_terms($taxonomy, $args);
$terms_count = $terms->count;
?>
<div class="jobs__types--wrapper">
<?php if ( $terms && !is_wp_error( $terms ) ) { ?>
<?php foreach ( $terms as $term ) { ?>
<a class="jobs__types--item" href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; echo get_term_link($term->slug, $taxonomy); ?><span> (<?php echo $term->count; ?>)</span></a>
<?php } ?>
<?php } ?>
<a class="jobs__types--item" href="">Spontaan solliciteren</a>
<a class="jobs__types--item" href="">Werken bij ons</a>
<a class="jobs__types--item" href="">Andere</a>
</div>
现在链接的网址是:https ://ago.staging.dfib.net/vacatures-type/maintenance-engineering/ 我想将其更改为:https ://ago.staging.dfib.net/vacatures /?search_keywords=&selected_jobtype=维护工程&selected_location=-1
我怎样才能从 slug 中获取“维护工程师”并在我需要的 url 中使用?
解决方案
推荐阅读
- python - 写入csv python3时的编解码器问题
- tensorflow - 使用 tensorfow 进行文本识别
- javascript - 第一次声明后无法覆盖 Javascript 变量
- java - 在与 java 应用程序集成时正确使用 MySQL docker 容器
- oracle - Oracle 包错误。PLS-00103:遇到符号“CREATE”
- javascript - 如何在 Firebase Cloud Firestore 中删除具有相同键值的集合中的文档
- c++ - 如何将我的班级 PID 引用到我的主目录?
- casting - 如何移动 Vec
> 走进 Vec >> - java - 页面对象模型 - 下拉菜单
- r - 使用 read_tsv 导入制表符分隔值表时遇到问题