wordpress - 使用 Stylepath 无法正确加载 Wordpress 页面
问题描述
我的代码中有一个错误,我找不到它的原因和来源。但我知道模板加载不正确。我相信问题可能从下面的代码开始。当我将 echo site_url 更改为 echo get_post_type_archive_link 时,问题就开始了。
单事件.php
<?php
get_header();
while(have_posts()) {
the_post(); ?>
<div class="page-banner">
<div class="page-banner__bg-image" style="background-image: url(<?php echo get_theme_file_uri('/images/ocean.jpg') ?>)"></div>
<div class="page-banner__content container container--narrow">
<h1 class="page-banner__title"><?php the_title();?></h1>
<div class="page-banner__intro">
<p>DONT FORGETT TO REPLACE ME LATER!!</p>
</div>
</div>
</div>
<div class="container container--narrow page-section">
<div class="metabox metabox--position-up metabox--with-home-link">
<p>
<a class="metabox__blog-home-link" href="<?php echo site_url('/blog'); ?>">
<i class="fa fa-home" aria-hidden="true"></i> Events Home</a>
<span class="metabox__main"><?php the_title(); ?></span>
</p>
</div>
<div class="generic-content"><?php the_content();?></div>
<h2>
<?php }
get_footer();
?>
单.php
<?php
get_header();
while(have_posts()) {
the_post(); ?>
<div class="page-banner">
<div class="page-banner__bg-image" style="background-image: url(<?php echo get_theme_file_uri('/images/ocean.jpg') ?>)"></div>
<div class="page-banner__content container container--narrow">
<h1 class="page-banner__title"><?php the_title();?></h1>
<div class="page-banner__intro">
<p>DONT FORGETT TO REPLACE ME LATER!!</p>
</div>
</div>
</div>
<div class="container container--narrow page-section">
<div class="metabox metabox--position-up metabox--with-home-link">
<p>
<a class="metabox__blog-home-link" href="<?php echo get_post_type_archive_link('event'); ?>">
<i class="fa fa-home" aria-hidden="true"></i> Blog Home</a>
<span class="metabox__main">Posted by <?php the_author_posts_link(); ?> on <?php the_time('n.j.y'); ?> in <?php echo get_the_category_list(', '); ?></span>
</p>
</div>
<div class="generic-content"><?php the_content();?></div>
<h2>
<?php }
get_footer();
?>
错误信息:
解决方案
推荐阅读
- excel - 在 MS Excel 中标记准重复项
- java - 我是否需要服务器才能将在我的应用程序中创建的 PDF 发送到另一台设备上的同一应用程序(不同帐户)?
- sql - SQL 查询没有整体执行
- node.js - 在 Linux Ubuntu 的 Windows 子系统中链接 Windows 命令
- javascript - 将鼠标悬停在一个元素上以使另一个元素可见
- javascript - Discord JS 遇到问题
- typescript - 我可以从通用参数推断枚举值吗?
- sql-server - 如何在左连接上的空值的情况下重复值
- request - SKStoreReviewController.requestReview() 费率不来 Appstore
- javascript - 无法从 api 访问数据