Php Wordpress-获取分类名称的一部分
你能帮我吗 我想把名字的一部分用在分类上 分类鼻涕虫:temporada-01 我只需要号码:01 我有这个代码,但这个显示的是名字Php Wordpress-获取分类名称的一部分,php,wordpress,taxonomy,Php,Wordpress,Taxonomy,你能帮我吗 我想把名字的一部分用在分类上 分类鼻涕虫:temporada-01 我只需要号码:01 我有这个代码,但这个显示的是名字 <?php $terms = get_the_terms( $post->ID , 'temporada' ); if ( $terms != null ){ foreach( $terms as $term ) { print $term->name; unset($term);
<?php
$terms = get_the_terms( $post->ID , 'temporada' );
if ( $terms != null ){
foreach( $terms as $term ) {
print $term->name;
unset($term);
}
}
?>
如何检索部分名称
谢谢。尝试通过('id',$post->id,'taxonomy\u name'获取术语)
尝试一个preg_replace()函数,该函数只保留数字:
print preg_replace( '/[^0-9]/', '', $term->name );
这将返回分类ID,否?我试试看。谢谢