admin管理员组文章数量:1026989
I have a php code as shown below in which I have added Line#A for the debugging purpose.
<div class="vidlist-main__meta cf">
<?php
//if ( has_excerpt() ) {the_excerpt();}
$tags = get_the_tags( get_the_ID() );
$cats = wp_get_post_categories( get_the_ID() ); // Line#Z
echo '<pre>'; print_r($cats); echo '</pre>'; // Line#A
if ( $tags || $cats ) : ?> // Line#B
<span class="archive-links">
<?php
\CPAC\Episodes\generate_markup_for_categories( $cats ); // Line#C
\CPAC\Episodes\generate_markup_for_tags( $tags ); // Line#D
?>
</span>
<?php endif;?>
</div>
On adding Line#A, I get the following o/p at different cases:
Case A:
Array
(
[0] => 13085
[1] => 13093
)
Case B:
Array
(
[0] => 1
[1] => 13087
)
Case C:
Array
(
[0] => 1
[1] => 13085
)
Problem Statement:
I am wondering what code I need to add after Line#Z or at Line#Z so that Line#Z takes only [1]=>13093
.
I have a php code as shown below in which I have added Line#A for the debugging purpose.
<div class="vidlist-main__meta cf">
<?php
//if ( has_excerpt() ) {the_excerpt();}
$tags = get_the_tags( get_the_ID() );
$cats = wp_get_post_categories( get_the_ID() ); // Line#Z
echo '<pre>'; print_r($cats); echo '</pre>'; // Line#A
if ( $tags || $cats ) : ?> // Line#B
<span class="archive-links">
<?php
\CPAC\Episodes\generate_markup_for_categories( $cats ); // Line#C
\CPAC\Episodes\generate_markup_for_tags( $tags ); // Line#D
?>
</span>
<?php endif;?>
</div>
On adding Line#A, I get the following o/p at different cases:
Case A:
Array
(
[0] => 13085
[1] => 13093
)
Case B:
Array
(
[0] => 1
[1] => 13087
)
Case C:
Array
(
[0] => 1
[1] => 13085
)
Problem Statement:
I am wondering what code I need to add after Line#Z or at Line#Z so that Line#Z takes only [1]=>13093
.
本文标签: categoriesHow to filter specific element of an array in wordpressphp
版权声明:本文标题:categories - How to filter specific element of an array in wordpressphp? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745667127a2162240.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论