admin管理员组文章数量:1310306
Guys. I started a new WP website about a month ago. Recently, I ran into two problems that I suspect have something to do with AJAX but I'm not sure. The first problem is the Media Library showing no items in the grid mode but everything is fine in the list mode. I didn't edit anything when the problem occurred so I don't know why...
The second problem is about ACF's Post Object Fields. In one of my Custom Post Type, I use Post Object and everything worked fine until recently, I found that when I assigned a new value to the field, pressed the update button and the edit page reloaded, the field on the edit page didn't show the new value but the front-end page did. In other words, the new value was successfully saved on the DB but for an unknown reason, the edit page couldn't show the value and became empty after the edit page reloaded. What made it weird was that the field's dropdown menu worked fine and showed all the options.
Since the two functions make use of AJAX, I wonder they have something to do with AJAX. Did anyone have the same problems? Thank you.
My WP version is WordPress 5.5.3 and ACF version is 5.9.1
Guys. I started a new WP website about a month ago. Recently, I ran into two problems that I suspect have something to do with AJAX but I'm not sure. The first problem is the Media Library showing no items in the grid mode but everything is fine in the list mode. I didn't edit anything when the problem occurred so I don't know why...
The second problem is about ACF's Post Object Fields. In one of my Custom Post Type, I use Post Object and everything worked fine until recently, I found that when I assigned a new value to the field, pressed the update button and the edit page reloaded, the field on the edit page didn't show the new value but the front-end page did. In other words, the new value was successfully saved on the DB but for an unknown reason, the edit page couldn't show the value and became empty after the edit page reloaded. What made it weird was that the field's dropdown menu worked fine and showed all the options.
Since the two functions make use of AJAX, I wonder they have something to do with AJAX. Did anyone have the same problems? Thank you.
My WP version is WordPress 5.5.3 and ACF version is 5.9.1
Share Improve this question asked Jan 25, 2021 at 9:38 Gary HuGary Hu 253 bronze badges 3- You need to contact ACF support, 3rd party plugin dev support is off topic here and not in this stacks scope – Tom J Nowell ♦ Commented Jan 25, 2021 at 9:48
- I'm sorry... I suspect both of the problems are related to AJAX so I put it here... – Gary Hu Commented Jan 25, 2021 at 10:00
- 1 For the media library issue you'll need more information. Turn off all plugins and turn them on one by one until the problem returns to identify the cause. Otherwise there are too many possible causes, be it filters, caching plugins, JS mistakes, etc etc – Tom J Nowell ♦ Commented Jan 25, 2021 at 10:06
1 Answer
Reset to default 0The problems turned out to have something to do with the sortable columns function I wrote before. Please see the function below.
function cpt_date_orderby( $query ) {
$orderby = $query->get( 'orderby' );
if( 'date' == $orderby ) {
$query->set('meta_key', 'date');
$query->set('orderby', 'meta_value_num');
}
}
add_action( 'pre_get_posts', 'cpt_date_orderby' );
The problem lies in line 3 where '$orderby' equaling 'date' is the condition. It seems 'date' is a reserved value that cannot be used for the condition for sorting, despite the fact that 'date' is a custom field I created with ACF. The solution is quite simple: Don't use 'date' but something else, for example, 'date1'.
Hope this helps those who are struggling with this problem.
本文标签: advanced custom fieldsTwo problems that are likely related to AJAX
版权声明:本文标题:advanced custom fields - Two problems that are likely related to AJAX 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741806448a2398532.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论