我需要获取所有可见(已发布)页面,然后确定它们使用的模板。我需要在标准WordPress API中执行此操作,而不是通过REST API。
有没有一个功能可以做到这一点?
我需要获取所有可见(已发布)页面,然后确定它们使用的模板。我需要在标准WordPress API中执行此操作,而不是通过REST API。
有没有一个功能可以做到这一点?
您可以使用get_pages
获取所有已发布的页面,类似于get_posts
, 像
<?php $args = array(
\'sort_order\' => \'asc\',
\'sort_column\' => \'post_title\',
\'hierarchical\' => 1,
\'exclude\' => \'\',
\'include\' => \'\',
\'meta_key\' => \'\',
\'meta_value\' => \'\',
\'authors\' => \'\',
\'child_of\' => 0,
\'parent\' => -1,
\'exclude_tree\' => \'\',
\'number\' => \'\',
\'offset\' => 0,
\'post_type\' => \'page\',
\'post_status\' => \'publish\'
);
$pages = get_pages($args); // get all pages based on supplied args
foreach($pages as $page){ // $pages is array of object
$page_template = get_post_meta($page->ID, \'_wp_page_template\', true); // Page template stored in "_wp_page_template"
echo $page_template;
}
?>
签出这些链接以了解更多详细信息:获取页面:https://codex.wordpress.org/Function_Reference/get_pages
获取页面模板:https://codex.wordpress.org/Function_Reference/get_page_template
对于我的客户端站点,当我尝试创建新页面并发布设计视图时,设计视图被破坏了,但博客帖子视图显示正确,该站点使用了以前的开发人员开发的自定义WordPress主题。Wp站点:http://blog.biblesforamerica.org页码:http://blog.biblesforamerica.org/online-bible-studies-bibles-america/如何做到这一点?这是单曲的代码。页php<div id=\"primary\" class=\"content-area\"&