[Resolved] Category above title for blog page and single posts

Home Forums Support [Resolved] Category above title for blog page and single posts

Home Forums Support Category above title for blog page and single posts

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #1306623
    Tom
    Lead Developer
    Lead Developer

    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.

    #1310482
    Matthew

    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

    #1310491
    Matthew

    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

    #1311492
    Tom
    Lead Developer
    Lead Developer

    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 🙂

    #1324625
    Matthew

    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,

    #1325352
    Tom
    Lead Developer
    Lead Developer

    In that case, you could try replacing:

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

    With:

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

    #1330889
    Matthew

    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

    #1331593
    Tom
    Lead Developer
    Lead Developer

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

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.