首页 > 解决方案 > 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
     }
  }
});

提前感谢您的时间。

标签: wordpresshyperlink

解决方案


解决方案是:我在面板中创建页面并像这样使用 slug:

<a href="<?php echo get_site_url().'/load-more-posts'; ?>">More Posts</a>

推荐阅读