Site logo

Archived topic

Category above title for blog page and single posts

22 replies · Started by Matthew on May 22, 2020

Viewing posts 16–23 of 23

That code will display terms in this taxonomy: genres

If your taxonomy is named custom_taxonomy_genres, you'll have to update the get_the_term_list() function to reflect that.

It's also assuming you're in a post type named pictures, whether in the archives or single posts.

Here is the top section of my Custom post type

function custom_post_type_pictures() {
	$labels = array(
		'name'			=> _x( 'Pictures', 'Post Type General Name' ),
		'singular_name'		=> _x( 'Picture', 'Post Type Singular Name' ),

Here is the top section of my Custom taxonomy

function custom_taxonomy_genres() {
	$labels = array(
		'name'			=> _x( 'Genres', 'taxonomy general name' ),
		'singular_name'		=> _x( 'Genre', 'taxonomy singular name' ),

Pls confirm I use Pictures and Genres

If this was a customizer setting it could be,

1) select regular/custom post

2) select category above/below title; or end of post etc

That code targets the pictures archive, so the page at yourwebsite.com/pictures

If a genre exists, it will display it above the title, as it is here: https://www.screencast.com/t/C9QVAWy84O

"Science Fiction" is the genre applied to that post.

So the code is working. Perhaps you're not trying to target the Pictures archive?

Looking through the thread to make sure I'm not missing anything. You said:

What’s still not working is the categories above the title on archives of my CPT.

This does seem to be working now.

Let me know :)

Interesting, and correct.

How can I also have this work for the home page, which I have been looking at and is probably the source of (my) confusion. Homepage/archives.

If you check out my index.html there is still missing category above title. Can I adjust the code.

thanks,

In that case, you could try replacing:

if ( is_post_type_archive( 'pictures' ) || is_singular( 'pictures' ) ) {

With:

if ( 'pictures' === get_post_type() ) {

Thanks Tom, functions great now.

A basic question;

I have the home page set to my latest posts under Reading Settings. Does this mean the homepage represents the official (and only) archive page of my regular posts, and if I changed that to a static page what post, page or URL etc would be my regular posts archives?

thanks

Your posts page is your "blog", so it's your base archive where all of your posts will display.

If you set it to a static page, your "blog" will now appear at that URL (/my-static-page).

This archived topic is closed to new replies.