wordpress - WordPress 页面模板超链接
问题描述
我只想知道如何使用标签链接到我的页面模板?
我创建了一个template-blogall.php
以此名称命名的页面模板:<?php /* Template Name: blog all */ ?>
我想<a href="my template url">blog</a>
在我的index.php
我搜索了很多,找不到我尝试过的任何解决方案
add_action('init', function() {
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH), '/');
if ( $url_path === 'retail' ) {
// load the file if exists
$load = locate_template('template-retail.php', true);
if ($load) {
exit(); // just exit if template was found and loaded
}
}
});
提前感谢您的时间。
解决方案
解决方案是:我在面板中创建页面并像这样使用 slug:
<a href="<?php echo get_site_url().'/load-more-posts'; ?>">More Posts</a>
推荐阅读
- java - 在java中使用赋值运算符时出错
- azure - 来自美国的 Azure AD B2C 登录
- php - 在 PHP 中发布日期后获取 RSS 提要
- python - 在熊猫中,从日期系列中减去日期以获得天数系列
- gitlab - GitLab:我怎样才能要求仅生产的手动步骤?
- python - 由两个正态变量的比率定义的分布中的值的概率(Python)
- html - 如何设置 ::before 元素的样式和位置,使其不影响按钮大小?
- php - 图像未显示在 ckeditor 中
- python - Python:如何根据日期时间获取值的计数
- graphql - 如何在 dgraph 查询中获取子字符串