首页 > 解决方案 > 应用过滤器时,帖子类型订单不起作用

问题描述

我正在使用这个 Post Type Order插件 它在 Wp-admin 自定义帖子列表中作为 ajax 拖放东西效果很好,但当我们按类别过滤帖子时不会重新排序。例如,它适用于

https://example.com/wp-admin/edit.php?post_type=schools

但如果我们在帖子列表中应用类别过滤器,则不起作用。

https://example.com/wp-admin/edit.php?s&post_status=all&post_type=schools&action=-1&m=0&schools_category=nyc&seo_filter&readability_filter&filter_action=Filter&paged=1&action2=-1

对于上述两种情况,它应该可以使用相同的拖放自定义重新排序帖子。

你能帮我吗,任何人。或任何其他建议。

这是插件文件中的Js代码

var getUrlParameter = function getUrlParameter(sParam) 
    {
        var sPageURL = decodeURIComponent(window.location.search.substring(1)),
            sURLVariables = sPageURL.split('&'),
            sParameterName,
            i;

        for (i = 0; i < sURLVariables.length; i++) {
            sParameterName = sURLVariables[i].split('=');

            if (sParameterName[0] === sParam) {
                return sParameterName[1] === undefined ? true : sParameterName[1];
            }
        }
    };

jQuery(document).ready(function()
    {

        jQuery('table.posts #the-list').sortable({
                                                    'items': 'tr',
                                                    'axis': 'y',
                                                    'update' : function(e, ui) {

                                                        var post_type           =   jQuery('input[name="post_type"]').val();
                                                        var order               =   jQuery('#the-list').sortable('serialize');

                                                        var paged       =   getUrlParameter('paged');
                                                        if(typeof paged === 'undefined')
                                                            paged   =   1;

                                                        var queryString = { "action": "update-custom-type-order-archive", "post_type" : post_type, "order" : order ,"paged": paged, "archive_sort_nonce"    :   CPTO.archive_sort_nonce};
                                                        //send the data through ajax
                                                        jQuery.ajax({
                                                          type: 'POST',
                                                          url: ajaxurl,
                                                          data: queryString,
                                                          cache: false,
                                                          dataType: "html",
                                                          success: function(data){

                                                          },
                                                          error: function(html){

                                                              }
                                                        });

                                                    }
                                                });


});

标签: phpjquerywordpresscustom-post-type

解决方案


该插件适用于所有过滤器,您可以在自定义帖子类型中使用自定义拖放重新排序帖子。 https://wordpress.org/plugins/intuitive-custom-post-order/


推荐阅读