On our WP install we have Topics pages which pull together any content which has been tagged with that topic. Standard.
When we visit the topic admin page and edit the Name field (so it's different to the Slug).
All of the referenced content which was on the topics page disappears. If we update the Slug to match the Name again it fixes the issue but then we are jeopardising our Search Engine positions if we're changing URL's.
I think this is a bug as surely the Slug should be independent to the Category Name so you can tweak the slug to remove unnecessary characters or words?
This is how the articles are being pulled into the template.
<?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') ?>
UPDATE: as requested here is what the Div looks like before (when it's "working" and the Name and Slug are the same):
and when we change the Name so it's not the same as the slug (which we need to be able to do and as far as i know should be standard WP functionality):
pre_get_posts
? also note that the API has functions for outputting URLs, likeget_term_link
, you should not be building those manually.