How can I change the URL for a single page in Wordpress?

♀尐吖头ヾ 提交于 2019-12-22 18:42:28

问题


I'm using wordpress as the CMS. I have developed a custom plugin to show dealers information.

below is the URL.

http://example.nl/dealer-info/dealer-informatie/?n=91&d=dealer-name

91 is the dealers ID which is used to fetch the data from the DB.

Is it possible for me to change to URL as below.

http://example.nl/dealer-info/dealer-informatie/91/dealer-name

or

http://example.nl/dealer-info/dealer-informatie/?n=91/dealer-name

My purpose is to just to add /dealer-name to the URL.

How can I change the URL for a single page in Wordpress?

Given that I don't want to change the permalinks which will affect the whole site. I'm aware the fact that this can be done using .htaccess but I don't the how to do it. Help me out if possible.


回答1:


Try:

RewriteEngine On
RewriteRule ^dealer-info/dealer-informatie/([0-9]+)/(.*)$ /dealer-info/dealer-informatie/?n=$1&d=$2 [L]

You'll want to add that before any wordpress specificf rules in your document root.




回答2:


If your custom post type were 'product', and/or query_var = "product", WordPress would look for single-product.php to display the single or permalink of the post.

Use single-{post_type}.php

For More Information refer to the below link:

http://codex.wordpress.org/Post_Type_Templates



来源:https://stackoverflow.com/questions/19626910/how-can-i-change-the-url-for-a-single-page-in-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!