duanchongzi9997 2017-02-16 19:28 采纳率: 0%
浏览 14
已采纳

发布的帖子不可查询,也不会显示在管理信息中心中

I have encountered this problem many times. This problem only happen when I programmatically create/edit posts. They could be customs post or even Wordpress' default post. The symptoms could be:

  • The posts are not visible in admin dashboard. Post count of that custom post type still increase but no post is displayed in the list.
  • Created posts are not query-able, even when post_status is set to 'any'. Curiously when I set post_status to published it works.

This is a self-answered question. I encountered this problem several times before and always forget its cause. And searches hint to possibilities that many others are stuck without solution too.

  • 写回答

1条回答 默认 最新

  • dsadsadsa1231 2017-02-16 19:28
    关注

    TL;DR;: It's publish, not published.

    The cause of this problem is because I when programmatically create new posts, I set its post_status to published. Common reason for the confusion is when you approve a post programmatically, switching post status from pending to published because it seem logical.

    The reason those posts are showing in neither queries nor admin dashboard is because WP_Query's post_status => 'any' doesn't actually query for 'any' post status as we expect, but any registered post status. Since wordpress had no prior knowledge of the post status published, they're simply ignored by the queries.

    Now here's to hope I don't forget what I wrote today again next year.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)