在我们的WP安装中,我们有主题页面,这些页面汇集了标记有该主题的任何内容。标准
当我们访问主题管理页面并编辑名称字段时(因此它与Slug不同)。
主题页面上的所有引用内容都将消失。如果我们再次更新Slug以匹配名称,它会解决问题,但如果我们更改URL,则会危及我们的搜索引擎位置。
我认为这是一个bug,因为Slug应该独立于类别名称,所以你可以调整Slug来删除不必要的字符或单词?
这就是文章被拉入模板的方式。
<?php
/*
Template Name: Search Knowledgebase
*/
?>
<!-- Page variables -->
<?php $page_id = \'help-and-advice\'; ?>
<?php
$args = array(
\'type\' => \'knowledgebase\',
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'taxonomy\' => \'knowledgebase_topics\',
\'pad_counts\' => false,
);
$categories = get_categories( $args );
$sub_id = \'templates\';
$subheader = true;
?>
<!-- Header -->
<?php include(\'partials/header.php\') ?>
<!-- Breadcrumb -->
<section id="breadcrumb">
<ul>
<li><a href="<?= bloginfo(\'url\') ?>/help-and-advice/">Help & Advice</a><span class="icon-chevron-thin-right"></span></li>
<li>Search</li>
</ul>
</section>
<!-- Hero -->
<?php include(\'partials/help-hero.php\') ?>
<?php
// echo "<pre>";
// print_r($categories);
// echo "</pre>";
?>
<section id="articles-result">
<div class="container">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $terms = get_the_terms( $post->id, \'knowledgebase_types\' ); ?>
<div class="article">
<h2><a href="<?= get_bloginfo(\'wpurl\').\'/help-and-advice/\'.$post->post_name?>"><?= $post->post_title ?></a></h2>
<p><?= excerpt(12) ?></p>
<?php
$author = get_userdata( $post->post_author );
?>
<div class="author">
<?php echo get_avatar( get_the_author_meta(\'email\') , 37, \'\', get_the_author()) ?>
<p><?= get_the_author() ?></p>
<div class="float-clear"></div>
</div>
<div class="topic">
<?php $terms = get_the_terms( $post->post_id, \'knowledgebase_topics\' );?>
<p><a href="<?= get_bloginfo(\'wpurl\').\'/help-and-advice/topics/\'.$terms[0]->slug ?>"><?= $terms[0]->name ?></a></p>
</div>
<div class="float-clear"></div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
<?php if ( !have_posts() ) : ?>
<h2 id="noresults">Sorry, we couldn\'t find anything that met your search criteria.</h2>
<?php endif; ?>
<div class="float-clear"></div>
<!-- Pagination -->
<div id="pagination">
<?php
$args = array(
\'end_size\' => 1,
\'mid_size\' => 2,
\'prev_text\' => __(\'<\'),
\'next_text\' => __(\'>\'),
);
echo paginate_links($args);
?>
</div>
</div>
</section>
<!-- Popular guides -->
<?php include(\'partials/popular-guides.php\') ?>
<!-- Footer -->
<?php include(\'partials/footer.php\') ?>
更新:根据要求,这里是Div之前的样子(当它“工作”并且名称和Slug相同时):
当我们更改名称使其与slug不同时(我们需要能够做到这一点,据我所知,这应该是标准的WP功能):