php - 在 WordPress 中插入自定义排序帖子代码的位置
问题描述
我正在按照高级自定义字段插件按 Wordpress 中的自定义字段值对帖子进行排序: https ://www.advancedcustomfields.com/resources/orde-posts-by-custom-fields/
我的问题是,我应该在主题编辑器上的哪些文件(.php)中插入代码片段?
解决方案
如果它的 wp_query 或 get_posts 您可以将它们直接插入到您希望它们出现的模板/帖子/页面文件中(或者您可以为它们创建一个函数)。
如果您使用的是 pre_get_posts,则需要将其添加到 functions.php 文件中。
推荐阅读
- r - Reshape2:dcast() 返回 - 'sum' 对因子没有意义
- elasticsearch - Elasticsearch - 将视频目录信息建模为一个索引与多个索引
- javascript - FontAwesome 图标未显示按钮
- java - 最终提交请求后,我在成功页面中得到空响应
- python - Kubernetes Python 客户端 - 一次查找待处理作业并安排所有 pod 或如何安排待处理作业
- mercurial - Windows 10 上的 Tortoisehg 工作台无法打开
- c++ - C++/WinRT,Windows SDK 17134 的一部分与 Visual Studio 15.8 Preview 3 不兼容
- php - 我只能在php中获取url参数的第一个数据
- android - keytool 错误:java.lang.Exception:别名
不存在 - javascript - 基于键/值对数组重新排序/分组