如何在两个不同的URL上用两个不同的帖子布局显示相同的帖子内容?
例如
https://www.domain.com/help-brothers/post-layout-1/post-name
https://www.domain.com/help-brothers/post-layout-2/post-name
如何在两个不同的URL上用两个不同的帖子布局显示相同的帖子内容?
例如
https://www.domain.com/help-brothers/post-layout-1/post-name
https://www.domain.com/help-brothers/post-layout-2/post-name
可以将布局名称作为GET
参数,然后在此基础上更改设计。因此,您的URL应该如下所示:
http://domain.com/post-name?layout=layout-1
现在在您的single.php
文件或呈现模板的任何文件,可以执行此检查以显示不同的布局:<?php
// If the header is different two, you should call for different headers too,
// Check this for showing different headers
// https://developer.wordpress.org/reference/functions/get_header/
if( isset( $_GET[\'layout\'] ) && $_GET[\'layout\'] == \'layout-1\' ) {
// Show the design for for the first layout
}
else if ( ... ) {
// Show the design for other layouts
}
我使用wp_get_archives() 并得到我所有档案的清单。但当我点击其中一个链接时,它总是将我重定向到front-page.php 这是www.mydomainexample.com.我创建了一个archive.php 请在我的目录中归档,以防您感到疑惑。我还保存了对永久链接的更改。在我的情况下,我想重定向到年份/日期。链接wp_get_archives() 已经生成我要找的内容www.mydomainexample.com/2020/12 但它总是重定向到我的主页www.mydomainexam