如何在自定义帖子类型发布URL的末尾添加查询字符串

时间:2017-08-08 12:58:24

标签: php jquery wordpress function

我正在搜索函数如何在自定义帖子类型发布网址的末尾添加查询字符串,例如:

www.example.com/post-type-category/post?abc=some_text&efg=some_text2

提前致谢

1 个答案:

答案 0 :(得分:0)

使用此代码:

var querystring = 'abc=some_text';
$('a').each(function()
{
    var href = $(this).attr('href');
    if(href.indexOf("post-type-category/post") > -1) {
        href += (href.match(/\?/) ? '&' : '?') + querystring;
        $(this).attr('href', href);
    }
});

其他示例:http://jsfiddle.net/xQ8hA/4/

相关问题