【问题标题】:change wordpress Permalink for a single costum post更改单个自定义帖子的 wordpress 永久链接
【发布时间】:2016-02-26 12:32:30
【问题描述】:

我正在使用带有永久链接结构的 wordpress:

http://www.example.com/article/

是否可以将带有 id 的 url 用于单个 costum 帖子?

类似这样的东西:http://www.example.com/postid=1234

【问题讨论】:

    标签: wordpress permalinks


    【解决方案1】:

    基于帖子 ID 的固定链接始终适用于所有帖子和页面,并且只会将您重定向到固定链接版本。

    默认:“丑”

    默认的样子

    @987654321@

    其中 N 是 Post ID 号。它适用于所有服务器环境,但看起来不如其他一些选项好。

    发件人:Using Permalinks

    【讨论】:

    • 是的......我只需要我的服装帖子像默认一样工作,其余的就像它一样......
    【解决方案2】:

    使用这个 如果您必须提供您使用的帖子类型

    function append_query_string( $url, $post ) {
      if ( 'product' == get_post_type( $post ) ) {
    
        return  $url."?postid=$post->ID" ;
      }
      return $url;
    }
    add_filter( 'post_type_link', 'append_query_string', 10, 2 );
    

    【讨论】:

    猜你喜欢
    • 2012-02-22
    • 2022-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-25
    • 1970-01-01
    • 1970-01-01
    • 2012-02-16
    • 1970-01-01
    相关资源
    最近更新 更多