从边栏中的小部件获取 post id
Get post id from widget in sidebar
我有一个侧边栏(测试侧边栏),其中包含带有自定义 post 的小部件。
如何从边栏(小部件)获取 posts?
我不想渲染 post 只得到他们的 ID
我使用的是 WordPress 版本 4.9.6
简而言之,您不能使用内置的 WordPress 小部件。
您将需要使用 WordPress Widget API. From there you will be able to develop a widget to complete whatever task you want. Otherwise it will be a trip to the WordPress plugin repo 创建您自己的小部件,以查看是否有人正在共享插件来执行您想要执行的操作。
附带说明一下,您可能还想看看构建 custom WP Query。这将允许您拉入任何您想要的帖子,然后在页面正文中操作它们。
我有一个侧边栏(测试侧边栏),其中包含带有自定义 post 的小部件。
如何从边栏(小部件)获取 posts? 我不想渲染 post 只得到他们的 ID
我使用的是 WordPress 版本 4.9.6
简而言之,您不能使用内置的 WordPress 小部件。
您将需要使用 WordPress Widget API. From there you will be able to develop a widget to complete whatever task you want. Otherwise it will be a trip to the WordPress plugin repo 创建您自己的小部件,以查看是否有人正在共享插件来执行您想要执行的操作。
附带说明一下,您可能还想看看构建 custom WP Query。这将允许您拉入任何您想要的帖子,然后在页面正文中操作它们。