【问题标题】:How to add query string at the end of the custom post type posts URL如何在自定义帖子类型帖子 URL 的末尾添加查询字符串
【发布时间】:2018-01-16 01:35:02
【问题描述】:

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

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

提前致谢

【问题讨论】:

  • 你是问如何使用$_GET变量?
  • 根据我的搜索@Grumpy,这与查询字符串有关
  • 你想用什么语言来做这个? javascript? php ?
  • 在任何语言中,如果是 php,我将使用 functions.php

标签: php jquery wordpress function


【解决方案1】:

使用此代码:

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/

【讨论】:

  • 它会添加到所有帖子中吗?
猜你喜欢
  • 2014-03-17
  • 1970-01-01
  • 2019-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多