我已经使用wordpress
和advanced custom fields
得到了这个工作代码:
$include = get_pages('include=1575');
$title = apply_filters('the_title',$include[0]->post_title);
$content = apply_filters('the_content',$include[0]->post_content);
我想创建一个var
取代include=1575
中的post_id
。我使用
$site_id = the_field('id_grundgedanke'); // output exp: 1575
我如何将这些组合起来?我尝试了以下操作:
$site_id = the_field('id_grundgedanke');
$include = get_pages('include=' . $site_id);
$title = apply_filters('the_title',$include[0]->post_title);
$content = apply_filters('the_content',$include[0]->post_content);
不工作
使用get_field()代替the_field()。
get_field() -返回指定字段的值。
the_field() -显示指定字段的值。这个函数与
echo get_field($field_name)
;
纠正代码:
$site_id = get_field('id_grundgedanke'); // use get_field
$include = get_pages("include=" . $site_id);
$title = apply_filters('the_title',$include[0]->post_title);
$content = apply_filters('the_content',$include[0]->post_content);