【发布时间】:2013-01-31 15:39:27
【问题描述】:
我的 WordPress 主题 functions.php 文件中有一个函数,代码如下:
function locations() {
$locations_list = array();
query_posts(array('orderby' => 'date', 'order' => 'DESC' , 'post_type' => 'location'));
while(have_posts()) {
$locations_list[the_slug()] = the_title();
}
wp_reset_query();
return $locations_list;
}
我的想法是我可以在我网站的任何地方运行这个函数,它将我所有的帖子存储在一个数组中。
但是,我不知道如何在公共端运行它:'(
完美的世界,我想在我的 footer.php 脚本中运行它。
任何帮助将不胜感激。
【问题讨论】:
标签: php arrays wordpress custom-fields