[Resolved] put categories into the normal post meta

  • Author
    Posts
  • #13233

    Volvo
    Participant

    help put categories into the normal post meta

    #13236

    Andrew Misplon
    Keymaster

    Hi

    Go to Plugins > Add New, search for and install a plugin called Code Snippets.

    Next, go to Snippets > Add New, name the snippet as you’d like and enter into the snippet body:

    if ( ! function_exists( 'polestar_post_meta' ) ) :
    /**
     * Print HTML with meta information for the sticky status, current post-date/time, author, comment count and post categories.
     */
    function polestar_post_meta() {
    	if ( ( is_home() || is_archive() || is_search() ) && get_theme_mod( 'post_date', true ) ) {
    		echo '<span class="entry-date"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date() ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span></a>';
    	}
    
    	if ( is_single() && get_theme_mod( 'post_date', true ) ) {
    		echo '<span class="entry-date"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date() ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span>';
    	}
    	
    	/* translators: used between list items, there is a space after the comma */
    	$categories_list = get_the_category_list( esc_html__( ', ', 'polestar' ) );
    	if ( $categories_list ) {
    		/* translators: 1: list of categories. */
    		printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', 'polestar' ) . '</span>', $categories_list ); // WPCS: XSS OK.
    	}	
    
    	if ( get_theme_mod( 'post_author', true ) ) {
    		echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a></span></span>';
    	}
    
    	if ( comments_open() && get_theme_mod( 'post_comment_count', true ) ) { 
    		echo '<span class="comments-link">';
    		comments_popup_link( esc_html__( 'Leave a comment', 'polestar' ), esc_html__( 'One Comment', 'polestar' ), esc_html__( '% Comments', 'polestar' ) );
    		echo '</span>';
    	}
    }
    endif;

    Change “Posted in” to the language of your choice.

    Enable “Only run on site front-end”, finally click Save changes and activate.

    #13237

    Andrew Misplon
    Keymaster

    Don’t copy the function from email, view this topic here on the forum and copy the function from the forum. Alternatively, copy the function from PasteBin: https://pastebin.com/raw/1SJHx2c2

    #13238

    Volvo
    Participant

    not work( Ah, we need to disable Post Categories
    Display the post categories on blog, archive and single post pages. and Remove CSS styles

    • This reply was modified 2 years, 8 months ago by Volvo.
    #13239

    Andrew Misplon
    Keymaster

    You’ll need to provide significantly more feedback for me to assist.

    #13241

    Volvo
    Participant

    That is all right

    #13242

    Volvo
    Participant

    Thank you so much!!!

    #13244

    Andrew Misplon
    Keymaster

    Glad to hear you’ve made progress.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Scroll to top