Site logo

[Resolved] Blog Category Above Title

Home Forums Support [Resolved] Blog Category Above Title

Home Forums Support Blog Category Above Title

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #316482
    Ali Rand

    Hi, is there a way on the Blog posts page to display the Categories above the Title, instead of the categories appearing after the title and any excerpt.

    Thanks,

    Ali

    #316544
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Are the categories the only thing you want above the title? What about tags?

    On the blog page only, or on the single post pages as well?

    Let me know 🙂

    #316699
    Ali Rand

    Hi Tom,

    Just the categories on the blog page would be helpful.

    Thanks.

    #316793
    Tom
    Lead Developer
    Lead Developer

    Give this a shot:

    add_filter( 'generate_category_list_output','tu_remove_categories' );
    function tu_remove_categories( $categories ) {
    	if ( is_home() || is_archive() ) {
    		return '';
    	}
    	
    	return $categories;
    }
    
    add_action( 'generate_before_entry_title','tu_cats_above_title' );
    function tu_cats_above_title() {
    	if ( is_home() || is_archive() ) {
    		$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
    		if ( $categories_list ) {
    			printf( '<span class="entry-meta cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    				_x( 'Categories', 'Used before category names.', 'generatepress' ),
    				$categories_list
    			);
    		}
    	}
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #316813
    Ali Rand

    Hey Tom,

    That code just removes the Categories for me. I added your code via a new Code Snippet fyi.

    #316819
    Tom
    Lead Developer
    Lead Developer

    Hmm, that second function should add them above. Can you link me to the page?

    #316820
    Ali Rand

    Thanks for looking into this…http://blue.yourtruesuccesspath.com/blog/

    #316930
    Tom
    Lead Developer
    Lead Developer

    Hmm.. In that second add_action() call, replace generate_before_entry_title with generate_before_content.

    #316936
    Ali Rand

    Ok, thanks, that moved it above the title. If it’s an easy fix, can it be below the featured image? So image, category, title…If not, then no worries. This will work for my next project. Thank you for your time!

    #316940
    Tom
    Lead Developer
    Lead Developer

    That’s what that first snippet of code should have done..

    I would need to log in to your site to see why that didn’t work. If you want me to, feel free to send temp admin login details: https://generatepress.com/contact/

    #317404
    Tom
    Lead Developer
    Lead Developer

    Do you have any custom files in your child theme? The account you sent me doesn’t have file editing permissions.

    #317507
    Ali Rand

    No, all the customizations are in Simple CSS. But you can take out any of them. It was for my working on my past client’s website, and it’s been transferred over.

    #317599
    Tom
    Lead Developer
    Lead Developer

    Any chance you can allow file editing? Basically I need to see why that before entry title hook isn’t firing. It was added a long time ago, so I’m confused as to why it wouldn’t work.

    #317601
    Ali Rand

    How do I enable that?

    #317602
    Ali Rand

    It’s a multisite, so Super Admin is the highest privilege. Does going to My Sites > Network Admin > Themes not allow you to edit the files?

Viewing 15 posts - 1 through 15 (of 22 total)
  • You must be logged in to reply to this topic.