HelpHub
HelpHub copied to clipboard
Category Terms Archive
Issue Description
While we have category term archive (such as this one), going one level up in URL returns error page (as found here).
It has been suggested to list all terms for the taxonomy on this page.
Any design suggestions?
cc @mapk
Are we up to continue discussion here or are we jumping to write the code?
cc @Kenshino @Clorith @ntwb
Isn't it the same thing as the home page? (for now, it is) A redirect might be the better option, as there is no template for this page. WP doesn't really handle it.
I encountered this also when working on a client site, and have discovered that there is an 8 year old ticket for it. But there are problems. A suggestion that would work easily is to create a Page with that slug and put a taxonomy widget in it (and explanatory text if desired). I was thinking of building this into my theme for my client's site, so I considered either putting all the taxonomies' widgets on the 404 page and/or making a page template that uses the slug as input to the taxonomy widget, so all you have to do is set the slug and choose that page template.
It's been decided to go with redirection. To home page preferably but some specific page template is also acceptable.
https://wordpress.slack.com/archives/C02RP4WU5/p1534779477000100
Are we going to redirect to home @Kenshino?
Are we talking about having a base template for wordpress.org/support/category and then list all the terms that we've got allocated in Categories?
If so i'm supportive. We need to get designs done for it ;)
I do this in my theme. I made it a function to use as a filter (which I add in the taxonomy-root template) or called directly (I call it from the 404 page).
/**
* Append a taxonomy term list to the passed parameter.
* Used in taxonomy-root page template and called in 404 template.
*/
function prefix_append_taxonomy( $content, $taxonomy = 'category' ) {
global $post, $wp;
if ( func_num_args() == 1 ) {
$taxonomy = ( $post && $post->post_name ) ? $post->post_name : wp_basename( $wp->request );
}
$out = wp_list_categories( array(
'taxonomy' => $taxonomy,
'orderby' => 'count',
'order' => 'DESC',
'show_count' => 1,
'title_li' => '',
'number' => 400, // Limit output.
'echo' => 0,
) );
if ( $out ) {
$content .= '<ul class="' . esc_attr( $taxonomy ) . ' taxonomy-list">'
. $out
. '</ul><!-- .taxonomy-list -->';
}
return $content;
}
And in the taxonomy-root template just add and remove the filter before and after the loop.
add_filter( 'the_content', 'prefix_append_taxonomy', 11, 2 );
//loop
remove_filter( 'the_content', 'prefix_append_taxonomy', 11 );
Then make a Page with whatever intro content is needed, using the slug of the taxonomy, and assign it the taxonomy-root template.