为什么根据帖子的perma-link查询页面会给我一个错误:
foreach ($serv as $servi) : //$serv is my array
$the_id = $servi->ID; // 94093
$get_perma_basename = basename(get_permalink($the_id)); //http://www.mywes.com/serv/my-page -> my-page
$get_prov = get_posts(array(
'post_type' => 'my_custom_post_type',
'meta_query' => array(
array(
'key' => 'serv', // name of the relationship field in all post with the custom post type
'value' => '"' . get_perma_basename . '"', //compare to see which entry in my custom post type has the `my-page` value
'compare' => 'LIKE'
)
)
));
我收到以下错误:
Notice: Use of undefined constant get_perma_basename - assumed 'get_perma_basename' in /var/www/my_site/check-for-page.php on line 310
行310
为'value' => '"' . get_perma_basename . '"'
如何解决问题以便正确查询
答案 0 :(得分:2)
尝试$get_perma_basename
(变量)而不是get_perma_basename
(常量)。