![](/img/trans.png)
[英]Passing two arrays in a jQuery .post() , how do I catch this data in PHP and use it there?
[英]How do i use php operators to add these two post id?
任何人都可以帮我处理这段代码? 我还在学习php,这是用于wordpress的。
如何将另一个帖子ID“1221”添加到此代码块中,以获得与帖子425相同的功能?
$additional_classes[] = ( is_object( $main_topic ) && 425 != $post->ID && !is_singular( $Theme->News->post_type ) ) ? 'term-' . $main_topic->slug : '';
提前致谢!!
可能最好不要使用if-quickhand语法来真正理解这一行中发生的事情:
if(
is_object( $main_topic ) //checks, if $main_topic is an object
&& (1221 != $post->ID || 425 != $post->ID ) //checks, if $post->ID is NOT 1221 NOR 425
&& !is_singular( $Theme->News->post_type ) //checks, if post_type is NOT singular
) {
$additional_classes[] = 'term-' . $main_topic->slug;
} else {
$additional_classes[] = '';
}
如果满足所有三个if语句/条件( &&
运算符),则将设置$additional_classes[]
,否则为空字符串。
$additional_classes[] = ( is_object( $main_topic ) && 1221 != $post->ID && !is_singular( $Theme->News->post_type ) ) ? 'term-' . $main_topic->slug : '';
希望能解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.