WordPress中查看所有页面信息
来源:互联网 发布:sql server 实训报告 编辑:程序博客网 时间:2024/06/04 18:51
欢迎转载!转载时请注明出处:http://blog.csdn.net/nfer_zhuang/article/details/51318917
引言
由于项目中大部分页面都是通过模板创建的,因此我需要统计一下所有页面各自的模板文件是什么。
另外,在知乎有这样的一个问题:wordpress的页面ID在哪里查看?,我的回答是:能用代码解决的问题,绝不手动去一个个的查看。
代码
直接上代码:
<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>查看页面列表</title> <style> table {border: 1px solid #cdcdcd;text-align: left;} td, th {padding-right: 10px;} </style></head><body> <div id="page-content"> <?php require( dirname(__FILE__) . '/wp-load.php' ); $pages = get_pages(); echo "<table >"; echo "<tr>"; echo "<th>index</th>"; echo "<th>ID</th>"; echo "<th>permalink</th>"; // echo "<th>post_type</th>"; // echo "<th>guid</th>"; echo "<th>post_title</th>"; echo "<th>post_name</th>"; // echo "<th>post_status</th>"; echo "<th>post_status</th>"; echo "</tr>"; $index = 0; foreach ($pages as $page) { echo "<tr>"; echo "<td>".$index++."</td>"; echo "<td>".$page->ID."</td>"; echo "<td>".get_permalink($page)."</td>"; // echo "<td>".$page->post_type."</td>"; // echo "<td>".$page->guid."</td>"; echo "<td>".$page->post_title."</td>"; echo "<td>".$page->post_name."</td>"; // echo "<td>".$page->post_status."</td>"; echo "<td>".get_page_template_slug($page)."</td>"; echo "</tr>"; } echo "</table>"; ?> </div></body></html>
代码比较简单,就不详细解释了。
其中post_title和post_name需要单独解释一下:
my post_name says one thing and my post_title says something else. Why are they different and how to I make them the same?
post_title is the post’s actual title. post_name is that post’s unique part of the permalink - sometimes called the slug.
– 摘自WordPress Support
而通过函数get_page_template_slug($page)
获取的就是模板文件,注意函数get_page_template_slug($page)
返回的是模板文件名:
Return: (string|false) Page template filename. Returns an empty string when the default page template is in use. Returns false if the post is not a page.
那么,如何获取模板名呢? $template = get_post_meta( $id, '_wp_page_template', true );
– 摘自http://themeforest.net/
- WordPress中查看所有页面信息
- wikia中所有页面的查看
- 查看手机所有信息
- 查看数据库中所有表的字段和字段信息
- 查看mysql中所有的外键信息
- Linux查看硬件所有信息
- vp_页面信息所有获取
- mysql,sqlserver和oracle中查看当前库中所有表和字段信息
- SQL-各种数据库中查看当前库中所有表和字段信息
- mysql和sqlserver中查看当前库中所有表和字段信息
- WordPress获取所有页面的id函数: get_all_page_ids
- 查看表的所有相关列信息
- MSSQL:查看所有触发器信息的命令
- SqlServer 查看所有触发器信息的命令
- SQL Server查看所有数据库文件信息
- MSSQL:查看所有触发器信息的命令
- 查看SQL-Server数据库所有触发器信息
- MongoDB 查看所有用户账号信息
- 12.IntelliJ IDEA 缓存和索引介绍和清理方法 - IntelliJ IDEA 使用教程
- 关于Android在线支付Alipay(支付宝)开发的经验分享,androidalipay
- Google Play Store如何换区
- s3c2440驱动程序_/*功能:使用查询方式读取按键值
- 安卓开发 第五篇 我的安卓应用架构设计-----Repository类
- WordPress中查看所有页面信息
- pythondb操作
- 【个人笔记】Linux学习笔记(持续更新)
- 13.IntelliJ IDEA 编译方式介绍 - IntelliJ IDEA 使用教程
- JAVA面向对象学习
- 简单自定义Toast
- 14.IntelliJ IDEA 项目相关的几个重要概念介绍 - IntelliJ IDEA 使用教程
- poj3041 最小点覆盖即最大匹配(匈牙利算法)(模板)
- 15.Hello World 项目创建与项目配置文件介绍 - IntelliJ IDEA 使用教程