首页 > 解决方案 > 在 WordPress 中插入自定义排序帖子代码的位置

问题描述

我正在按照高级自定义字段插件按 Wordpress 中的自定义字段值对帖子进行排序: https ://www.advancedcustomfields.com/resources/orde-posts-by-custom-fields/

我的问题是,我应该在主题编辑器上的哪些文件(.php)中插入代码片段?

标签: phpwordpressadvanced-custom-fieldscustom-fields

解决方案


如果它的 wp_query 或 get_posts 您可以将它们直接插入到您希望它们出现的模板/帖子/页面文件中(或者您可以为它们创建一个函数)。

如果您使用的是 pre_get_posts,则需要将其添加到 functions.php 文件中。


推荐阅读