• Hi all. I’m back to wordpress after a few years and I’m quite… rusty ??
    I’m trying to display in the home page articles with date (ok) title (ok) no author name (ok) and category (KO): I do not understand how to show the category related to the article.
    Thank you in advance!
    https://www.dialoghitributari.it

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • where do you want to show the categories?
    below the title, below the excerpt?
    same as in single post view?
    same formatting? different formatting?

    are you already using a child theme?

    generally, the code to show the post is done via /template-parts/post/content.php (unless you are using post formats).

    and the section to show the category is done (conditionalyy for single posts only):

    	<?php if ( is_single() ) : ?>
    		<?php twentyseventeen_entry_footer(); ?>
    	<?php endif; ?>
    

    remove the condition, and the categories will also show in the posts page.

    • This reply was modified 4 years, 8 months ago by Michael.
    Thread Starter marelloe

    (@marelloe)

    Thank you Michael!

    where do you want to show the categories?
    below the title, below the excerpt?
    same as in single post view?
    same formatting? different formatting?

    the best solution for me will be the same line of the date, same format of the date

    are you already using a child theme?

    good question… I messed up a lot. In a first time I used one, actually I think I’m not using it

    one way of doing it, would be to edit content.php in /template-parts/post/ (in a child theme or not) and replace this section:

    			echo '<div class="entry-meta">';
    			if ( is_single() ) {
    				twentyseventeen_posted_on();
    			} else {
    				echo twentyseventeen_time_link();
    				twentyseventeen_edit_link();
    			};
    			echo '</div><!-- .entry-meta -->';
    

    with:

    			echo '<div class="entry-meta">';
    			
    				twentyseventeen_posted_on();
    				if( is_home() ) : 
    					//categories output//
    					/* translators: used between list items, there is a space after the comma */
    					$separate_meta = __( ', ', 'twentyseventeen' );
    
    					// Get Categories for posts.
    					$categories_list = get_the_category_list( $separate_meta );
    
    					if ( ( $categories_list && twentyseventeen_categorized_blog() ) ) {
    					echo ' /<span class="cat-tags-links"> ';
    					// Make sure there's more than one category before displaying.
    						echo '<span class="cat-links">' . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>';
    				
    					echo '</span>';
    					}
    					twentyseventeen_edit_link();
    				endif;
    			
    			echo '</div><!-- .entry-meta -->';
    
    Thread Starter marelloe

    (@marelloe)

    Sorry but it does not work

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display category in articles’ is closed to new replies.