dqnz43863 2011-01-19 23:57
浏览 12

返回WordPress中的所有page_names,没有多余的?

I need to retrieve an array of every page_name registered in WordPress. I've got two issues, I can do a get_pages() and such, but it literally pulls every freakin thing about each page including their content. Totally unnecessary overhead when all I need is page_name for each.

The other is that I'd like to do it with a built in method if possible, as this is for an in-house plugin and we'd like to keep it compatible with the mainline. (worst case will just access the DB directly and get them) I know you can include/exclude in the get_pages() call, but I haven't figured out if it is possible to exclude retrieving everything but one, instead of the opposite.

It needs to be dynamic in that it cannot have any hard-coded strings i.e. know anything about the pages themselves or what they're called. Also no extra junk like it being in an unordered list or something. Straight up array, no levels needed. (sub-pages are listed same as primary)

Any ideas guys? I've searched and searched..but the documentation is retarded for these types of things as you guys probably know.

Thanks.

Example of what I'd like in the end or similar:

Array
(
    [0] => stdClass Object
        (
            [page_name] => 'page1'
        )
    [1] => stdClass Object
        (
            [page_name] => 'page2'
        )
    [2] => stdClass Object
        (
            [page_name] => 'page3'
        )
    [3] => stdClass Object
        (
            [page_name] => 'page4'
        )
)
  • 写回答

3条回答 默认 最新

  • dtdt0454 2011-01-20 00:12
    关注

    I checked get_pages() source code and there's no way you can limit what's being requested from a database. Pages are fetched at lines 3177-3184, and as you can see, there's a hardcoded SELECT * FROM query.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看