[Resolved] show the categories and the date above the title

Home Forums Support [Resolved] show the categories and the date above the title

Home Forums Support show the categories and the date above the title

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #339561
    dmmaso

    Hi,
    There is some way in the blog page and in the pages of a single post to show the categories and the date above the title, in this order.

    Thank you

    Daniel

    #339689
    Tom
    Lead Developer
    Lead Developer

    What about the author and tags? Do you want them to appear above as well?

    #339817
    dmmaso

    No. I just want category, date and title in this order

    #340500
    Tom
    Lead Developer
    Lead Developer

    First, we’d need to move it above the title:

    add_action( 'after_setup_theme','tu_move_posted_on' );
    function tu_move_posted_on() {
        remove_action( 'generate_after_entry_title', 'generate_post_meta' );
        add_action( 'generate_before_entry_title', 'generate_post_meta' );
        add_filter( 'generate_category_list_output', '__return_false' );
    }

    Then you’d need to do this:

    add_filter( 'generate_post_date_output', 'tu_categories_to_date' );
    function tu_categories_to_date( $output ) {
        $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
        $categories_list = sprintf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
            _x( 'Categories', 'Used before category names.', 'generatepress' ),
            $categories_list
        );
    
        return $categories_list . $output;
    }
    #340545
    dmmaso

    Great Tom !! thank you very much again!!

    #340773
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

    #645077
    I

    Hi Tom I just want to move category & tags above title. I have date and author at bottom of post, I can’t seem to make this work.

    #645360
    Tom
    Lead Developer
    Lead Developer

    I wonder if you could do something as simple as this:

    remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
    add_action( 'generate_before_entry_title', 'generate_footer_meta' );

    Let me know ๐Ÿ™‚

    #645619
    I

    It works but includes all the meta data, rather than just category and tag, and it doesn’t remove the bottom. I’ll keep trying.

    #645837
    Tom
    Lead Developer
    Lead Developer

    Let’s try this instead then:

    add_filter( 'generate_show_categories', '__return_false' );
    add_filter( 'generate_show_tags', '__return_false' );
    
    add_action( 'generate_before_entry_title', function() {
        $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="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>', // WPCS: XSS ok, sanitization ok.
                esc_html_x( 'Categories', 'Used before category names.', 'generatepress' ),
                $categories_list
            );
        }
    
        $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
        if ( $tags_list ) {
            printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>', // WPCS: XSS ok, sanitization ok.
                esc_html_x( 'Tags', 'Used before tag names.', 'generatepress' ),
                $tags_list
            );
        }
    } );
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.