【发布时间】:2012-10-25 10:15:30
【问题描述】:
我正在尝试根据当前的 Wordpress 页面或子页面显示内容,使用页面标题而不是 ID。
我拥有的是这样的:
<?php if ( is_page( array( 'About', 'Chi Siamo' ) ) || ( get_the_title( $post->post_parent ) == ( array( 'About', 'Chi Siamo' ) ) ) ) { ?>
<p>Hello Joe</p>
<?php } else {} ?>
不知道为什么,但它正在识别页面名称,而不是该页面的子页面。
谁能看到我做错了什么?语法错误?
谢谢
附言。我也试过了
<?php if (get_the_title() || get_the_title( $post->post_parent ) == array( 'About', 'Chi Siamo' ) ) { ?>
但这对所有页面都返回 true。
【问题讨论】:
-
你的第一个条件似乎有点小括号快乐
-
True :) 我无法通过父页面名称识别子页面,因为没有内置函数可以做到这一点 - 你能推荐什么吗?
标签: wordpress if-statement parent-child