首页 \ 问答 \ 如何使用/ blog替换/ category和/ tag,同时将/ blog添加到不带插件的WordPress网址中(How to replace /category and /tag with /blog while adding /blog to posts in a WordPress URL without plugins)

如何使用/ blog替换/ category和/ tag,同时将/ blog添加到不带插件的WordPress网址中(How to replace /category and /tag with /blog while adding /blog to posts in a WordPress URL without plugins)

我想在不使用插件的情况下调整wordpress站点的永久链接。 我希望在为所有博客相关网站(类别和标签概览加上帖子)添加前缀“/ blog”时摆脱“/ category”和“/ tag”。

我使用了几个类别,包括子类别以及标签,但没有自定义帖子类型。 例如:

  • 类别“动物”与子类别“狗”,“猫”和标签“宠物食品”
  • 每个子类别有一个帖子,每个帖子都标有“宠物食品”
  • 在www.example.com上托管

对于页面,我不需要导致www.example.com(/ page-A)的任何定制。 对于职位,以下结构将是理想的:

(1)www.example.com/blog; 显示全部三个帖子

(2)www.example.com/blog/animals; 显示全部三个帖子

(3)www.example.com/blog/animals/dogs; 显示关于狗的一篇文章

(4)www.example.com/blog/animals/dogs/post-about-dogs; 阅读关于狗的帖子

(5)www.example.com/blog/pet-food/; 显示全部三个帖子

我尝试了迄今为止的几种方法。 首先我去设置 - >永久链接,并选择了自定义永久链接选项添加

/博客/%类别%/%postname%/

同时保持类别和标签基本选项不变。 在这里,除2,3和5情况下仍然显示“/ category”和“/ tag”外,所有工作都在进行。

通过添加“。” 进入可选的类别库中,“/ category”在情况2中消失,但现在情况3的url(有和没有“/ category”)不起作用。 案例5仍未解决。

通过添加“/ blog”而不是“。”。 案例2和案例3将按照既定目标工作,但没有“/类别”,但现在情况4和案例5被打破。

我尝试了几种其他的组合方式,同时也改变了标签基础,并且没有任何方法可以处理每一个链接变化。 我甚至尝试了几次重置不同设置之间的htaccess文件,但没有成功。

我已经考虑从WordPress网址中删除类别和标签库 - 没有插件和其他几十个网站。 但不幸的是,迄今为止,没有配置为我工作。 我甚至试图用Yoast SEO提供的选项去除“/ category”(这已经安装了,如果需要的话可以使用什么),但是这也导致了“/ blog”的切割。

任何帮助非常感谢 - 如果你有解决这个问题的解决方案,这将是非常好的!


I would like to adjust the permalinks of my wordpress site without using a plugin. I want to get rid of "/category" and "/tag" while adding a prefix "/blog" to all blog related sites (category and tag overview plus posts).

I use several categories including sub-categories as well as tags but no custom post types. For example:

  • Category "animals" with sub-categories "dogs", "cats" and a tag "pet-food"
  • One post per sub-categorie, each tagged with "pet-food"
  • Hosted on www.example.com

For pages I don't need any customization resulting in www.example.com (/page-A). For posts the following structure would be ideal:

(1) www.example.com/blog; Showing all three posts

(2) www.example.com/blog/animals; Showing all three posts

(3) www.example.com/blog/animals/dogs; Showing the one post about dogs

(4) www.example.com/blog/animals/dogs/post-about-dogs; Reading the post about dogs

(5) www.example.com/blog/pet-food/; Showing all three posts

I tried so far several approaches. First of all I went to settings -> permalinks and chose the custom permalink option adding

/blog/%category%/%postname%/

while leaving the category and tag base options untouched. Here everything is working besides that "/category" and "/tag" still show up in cases 2,3 and 5.

By adding a "." into the optional category base the "/category" disappears in case 2 but now the url of case 3 (with and without "/category") isn't working. Case 5 is still unfixed.

By adding "/blog" instead of "." case 2 and 3 will work both without "/category" as intended but now cases 4 and 5 are broken.

I tried several other combinations with also changing the tag base and in none approach every link variation worked. I even tried a couple of times to reset the htaccess file in between different settings with no success.

I already considered Remove category & tag base from WordPress url - without a plugin and dozens of other sites. But unfortunately no configuration worked for me so far. I even tried to strip of the "/category" with the option provided by Yoast SEO (which is already installed and what can be used if needed) but this resulted into also cutting of "/blog".

Any help is much appreciated - it would be great if you have a solution for this problem!


原文:https://stackoverflow.com/questions/48262434
更新时间:2023-04-08 06:04

最满意答案

使用string.match和patterns:

local url = "http://ip/rgb/color?R=200&G=100&B=300"
local r,g,b= url:match("R=(%d+)&G=(%d+)&B=(%d+)")
print (r,g,b)

Use string.match and patterns:

local url = "http://ip/rgb/color?R=200&G=100&B=300"
local r,g,b= url:match("R=(%d+)&G=(%d+)&B=(%d+)")
print (r,g,b)

相关问答

更多
  • 以上评论是现货! 以下是我更新的内容...... language_name ?> Above commen ...
  • 得到它了 function getUrlParam (paramName) { var str = window.location.search; var result = {}; str.replace(/([^?=&]+)(?:[&#]|=([^&#]*))/g, function (match, key, value) { if (key.indexOf("[]") !== -1) { key = key.replace(/\[\]$/, ...
  • 您可以使用grok过滤器来匹配您的URL中的params: filter { grok { match => [ "message", "%{URIPARAM:url}" ] } 然后你可能必须使用kv过滤器来分割你的数据: kv { source => "url" field_split => "&" } 这个StackOverflow帖子可能会变得很方便。 希望这可以帮助! You could use the grok filter to match your p ...
  • 您应该使用NameValueCollection而不是字符串数组。 NameValueCollection queryParameters = new NameValueCollection(); string[] querySegments = queryString.Split('&'); foreach(string segment in querySegments) { string[] parts = segment.Split('='); if (parts.Length > 0) ...
  • 使用string.match和patterns: local url = "http://ip/rgb/color?R=200&G=100&B=300" local r,g,b= url:match("R=(%d+)&G=(%d+)&B=(%d+)") print (r,g,b) Use string.match and patterns: local url = "http://ip/rgb/color?R=200&G=100&B=300" local r,g,b= url:match("R=(%d+) ...
  • 我们必须定义参数。 在url或params : {}对象。 所以这应该解决它: .state("workPlan.list", { //url: "MainPage", url: "MainPage?myParam", // here we say, that myParam is expected in url 其他如何设置params Angular ui路由器在没有URL的状态之间传递数据 如何使用ui-router中的ui-sref将参数传递给控制器 We must defin ...
  • 你试过路径变量吗? @RequestMapping(value = "/filterSearch.html/{level1}/{level3}") public final Object filterSearch(@PathVariable("level1")String level1, @PathVariable("level3"), String level3) Have you tried path variables? @RequestMapping(value = "/filterSearch ...
  • 这样的事情? var parts = window.location.pathname.split('/'); //pathname to array parts.splice(parts.length-1,1); // kill the last key var newpathname = parts.join('/'); // reassemble self.location.href = window.location.protocol+'://'+window.location.host+'/'+ ...
  • 这不是游戏问题。 您将在浏览器中运行的任何内容中遇到此问题,因为片段只是客户端。 W3指出 : 在他的一个XHTML页面中,Dirk创建了一个指向Nadia在Web上发布的图像的超文本链接。 他创建了一个带有“ http://www.example.com/images/nadia#hat ”的超文本链接。 Emma在她的Web浏览器中查看Dirk的XHTML页面并按照链接进行操作。 浏览器中的HTML实现从URI中删除片段并请求图像“ http://www.example.com/images/nadia ...
  • 好! 我在文件system / core / uri.php中编写了一个函数 function assing_segment($num,$value) { $this->segments[$num] = $value; return $this->segments[$n]; } 并在视图或控制器中调用此函数 $this->uri->assing_segment(5,$myvalue); 这将使我的价值重新分配第5部分 Well! i wrote a function in the ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)