- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想更改特定自定义帖子类型的永久链接结构。即
http://test.com/brand/calvin-klien?mtype=tab2
^this is dynamic
http://test.com/brand/calvin-klien/mtype/tab2
^this is dynamic
function custom_rewrite_tag() {
add_rewrite_tag('%mtype%', '([a-z0-9\-]+)');
}
add_action('init', 'custom_rewrite_tag', 10, 0);
add_action('init', 'wpse50530_journal_archive_rewrite', 10, 0);
function wpse50530_journal_archive_rewrite(){
add_rewrite_rule('brand/([a-z0-9\-]+)/([a-z0-9\-]+)/$','index.php?name=$matches[1]/?mtype=$matches[2]','top');
}
add_action('generate_rewrite_rules', 'work_list');
function work_list($wp_rewrite) {
$newrules = array();
$newrules['brand/([a-z0-9\-]+)/([a-z0-9\-]+)/$'] = 'index.php?name=$matches[1]&mtype=$matches[2]';
$wp_rewrite->rules = $newrules + $wp_rewrite->rules;
codes
,
flushed permalinks
但仍然是
404
.我不知道它为什么要创建
$匹配在 htaccess 中,因为 htacces 不知道是什么
$匹配
404
.请参阅代码 1 和代码 2 的附加屏幕截图
最佳答案
以下代码应该会有所帮助
add_action( 'init', 'so_27487849' );
function so_27487849() {
add_rewrite_rule(
'^brand/([^/]*)/mtype/([^/]*)/?',
'index.php?name=$matches[1]&mtype=$matches[2]',
'top');
}
关于Wordpress add_rewrite_rule 给出 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27487849/
我正在尝试使用 wordpress 的 add_rewrite_rule 函数添加自定义规则,但它们不起作用。奇怪的是,每当我使用 检查规则时,都会添加规则并匹配我的 URL。 Monkeyman 重
目标 一个可见的 URL: /products/building-automation/details/productSKU 应该指向真实的 WordPress 页面: /products/detai
我想更改特定自定义帖子类型的永久链接结构。即 http://test.com/brand/calvin-klien?mtype=tab2 ^this is d
我可以得到 add_rewrite_rule使用 MAMP 在本地工作,但不在我的 DreamHost 生产服务器上工作。 我正在尝试美化个人宠物的网址 http://www.pawsnewengla
我是 Stack Overflow 的新手。 我正在使用 Wordpress 3.9,我正在尝试使用以下方法重写 URL,该方法位于 functions.php 中: 我用这个方法: add_rewr
我有一个名为“People”的页面,其中包含一个自定义模板,该模板接受一个名为 name 的变量: example.com/people/?name=FirstLast 我想要的是这个: exampl
我正在尝试匹配以下网址: planets/animals-and-more/animal/human 收件人: index.php?pagename=animal&animal-name=human
我正在尝试执行以下操作: 重写我的 WordPress 安装的 URL 结构,以便在其中包含语言字段。例如http://www.mydomain.com/lang/ 然后我想从/lang/获取输入并使
我是一名优秀的程序员,十分优秀!