上周4.5发布时,我开始注意到一些问题,错误地认为是更新导致了问题。事实上,我只是碰巧在那时第一次注意到它,因为上周是第一次创造一系列条件。有了这些知识,我想知道是否有人能帮我找出我在解决问题时遗漏了什么。
作为背景,我使用一个PHP脚本在铜版画廊上显示画廊缩略图,并使用参数处理分页mdgpage
对于初始页面上的任何页面(类似于内置page
参数)。我在不同URL深度的页面上使用它,自从它运行以来,我没有遇到过任何问题。为了更好地组织,我们已经开始创建自己的自定义帖子类型。这已经很好地工作了,但是上周是第一次在自定义帖子类型条目中的库对多个页面进行了调整,随后的库对404页进行了调整。
我感到困惑的是,为什么页面和自定义帖子类型(以及标准帖子,尽管我不打算在这些类型中使用图库)在这个意义上表现不同。检查重写规则和正则表达式意味着两者没有区别。以下是我为query\\u vars和rewrite\\u规则设置的内容:
function add_query_vars($aVars) {
$aVars[] = "mdgpage"; // represents the name of the product category as shown in the URL
return $aVars;
}
// hook add_query_vars function into query_vars
add_filter(\'query_vars\', \'add_query_vars\');
function add_rewrite_rules($aRules) {
$aNewRules = array(\'(.?.+?)/mdgpage/([^/]+)/?$\' => \'index.php?pagename=$matches[1]&mdgpage=$matches[2]\');
$aRules = $aNewRules + $aRules;
return $aRules;
}
// hook add_rewrite_rules function into rewrite_rules_array
add_filter(\'rewrite_rules_array\', \'add_rewrite_rules\');
以下是我们所做的CPT声明:
function md_custom_doujinshi_en() {
$labels = array(
\'name\' => _x( \'Doujinshi (en)\', \'post type general name\' ),
\'singular_name\' => _x( \'Doujinshi (en)\', \'post type singular name\' ),
\'add_new\' => _x( \'Add Doujinshi (en)\', \'Doujinshi (en)\' ),
\'add_new_item\' => __( \'Add Doujinshi (en)\' ),
\'edit_item\' => __( \'Edit Doujinshi\' ),
\'new_item\' => __( \'New Doujinshi\' ),
\'all_items\' => __( \'All Doujinshi (en)\' ),
\'view_item\' => __( \'View Doujinshi\' ),
\'search_items\' => __( \'Search Doujinshi\' ),
\'not_found\' => __( \'No Doujinshi found\' ),
\'not_found_in_trash\' => __( \'No Doujinshi found in the Trash\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Doujinshi\'
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Miss Dream Doujinshi (en)\',
\'public\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'comments\' ),
\'has_archive\' => false,
\'register_meta_box_cb\' => \'md_doujinshi_metaboxes\',
\'rewrite\' => array(\'slug\' => \'sailor-moon-doujinshi\')
);
register_post_type(\'doujinshi_en\', $args);
}
add_action(\'init\', \'md_custom_doujinshi_en\');
function md_custom_doujinshi_jp() {
$labels = array(
\'name\' => _x( \'Doujinshi (jp)\', \'post type general name\' ),
\'singular_name\' => _x( \'Doujinshi (jp)\', \'post type singular name\' ),
\'add_new\' => _x( \'Add Doujinshi (jp)\', \'Doujinshi (jp)\' ),
\'add_new_item\' => __( \'Add Doujinshi\' ),
\'edit_item\' => __( \'Edit Doujinshi\' ),
\'new_item\' => __( \'New Doujinshi\' ),
\'all_items\' => __( \'All Doujinshi (jp)\' ),
\'view_item\' => __( \'View Doujinshi\' ),
\'search_items\' => __( \'Search Doujinshi\' ),
\'not_found\' => __( \'No Doujinshi found\' ),
\'not_found_in_trash\' => __( \'No Doujinshi found in the Trash\' ),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Miss Dream Doujinshi (jp)\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => \'edit.php?post_type=doujinshi_en\',
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'comments\' ),
\'has_archive\' => false,
\'register_meta_box_cb\' => \'md_doujinshi_metaboxes\',
\'rewrite\' => array(\'slug\' => \'raw-sailor-moon-doujinshi\')
);
register_post_type(\'doujinshi_jp\', $args);
}
add_action(\'init\', \'md_custom_doujinshi_jp\');
在页面和自定义帖子类型中,库脚本都设置为在内容中间运行和显示。我使用插件来设置
aid
并在页面中包含脚本。对于自定义帖子类型,相同的行被编码到页面模板中
aid
通过其中一个Posteta字段设置。
如果您能给我提供任何帮助或建议,我将不胜感激。非常感谢。