【问题标题】:WordPress, how to use dynamic urls for the same page?WordPress,如何为同一页面使用动态网址?
【发布时间】:2020-09-03 14:48:28
【问题描述】:

我不知道这是否可能,但我想配置一个 WordPress 网站,为所有匹配 https://example.com/things/<any_word> 格式的 URL 呈现相同的页面,该 URL 必须保持其值。

例如,

以下网址必须显示相同的内容:

非常感谢您的帮助

【问题讨论】:

    标签: wordpress url


    【解决方案1】:

    有几种选择:

    1) 注册您的自定义帖子类型并创建默认模板(最佳选择)

    2) 向页面模板(single.php 或 page.php ...)添加一些自定义代码,您可以在其中调用特定类别的特定模板:

     <?php  
      if (get_the_category(get_the_id())=='your-category')     
    {
         
    get_template_part( 'TEMPLATE_FOLDER/content', 'something' ); // "content-something.php"   
    
    }    ?>
    

    3) 创建模板并为需要的页面选择模板

    https://developer.wordpress.org/themes/template-files-section/page-template-files/ https://developer.wordpress.org/reference/functions/register_post_type/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-14
      • 1970-01-01
      • 2018-07-28
      • 1970-01-01
      • 1970-01-01
      • 2021-04-29
      相关资源
      最近更新 更多