Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category Terms Archive #231

Open
zzap opened this issue Jun 18, 2018 · 6 comments
Open

Category Terms Archive #231

zzap opened this issue Jun 18, 2018 · 6 comments

Comments

@zzap
Copy link
Member

zzap commented Jun 18, 2018

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

@joyously
Copy link
Contributor

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.

@joyously
Copy link
Contributor

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.

@zzap
Copy link
Member Author

zzap commented Aug 20, 2018

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

@zzap
Copy link
Member Author

zzap commented Jul 1, 2019

Are we going to redirect to home @Kenshino?

@Kenshino
Copy link
Collaborator

Kenshino commented Jul 8, 2019

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 ;)

@joyously
Copy link
Contributor

joyously commented Jul 8, 2019

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.

@zzap zzap added the design label Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants