Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #84143
    Kenta
    Participant

    Hi Sakin

    Could you please help me display “tag” next to meta (date and author) in the excerpt of on top page. It’s not customizable through theme option settings.

    My website is http://kenta-kiyomiya.com

    Thank you

    #84216
    Mahesh
    Participant

    Hi @Kenta,

    For this, you’ll need to create a child theme. You can find more details on creating child theme HERE. Then in your child theme’s functions.php, add the following codes.

    /**
     * Adding tags in header_meta
     *
     */
    function adventurous_header_meta() {
    
    	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() )
    	);
    
    	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'adventurous' ), get_the_author() ) ),
    		get_the_author()
    	);
    
    	// Translators: used between list items, there is a space after the comma.
    	$tag_list = get_the_tag_list( '', __( ', ', 'adventurous' ) );
    
    	// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
    	if ( $tag_list ) {
    		$utility_text = __( '<span class="on-date">Posted on %1$s</span><span class="by-author"> by %2$s</span> | </span><span class="in-tag">Tagged %3$s</span>', 'adventurous' );
    	}else{
    		// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
    		$utility_text = __( '<span class="on-date">Posted on %1$s</span><span class="by-author"> by %2$s</span>', 'adventurous' );
    	}
    
    	printf(
    		$utility_text,
    		$date,
    		$author,
    		$tag_list
    	);
    }

    Regards,
    Mahesh

    #84314
    Kenta
    Participant

    Hi Mahesh,

    Thank you so much for your quick reply, and your advice worked out.
    Based on your advice, I tried to give small changes to the order of meta information such as tag, date, author, category, which turned out fine.
    (see http://kenta-kiyomiya.com)

    By the way, I would like to make clear why the above code should be added to function.php NOT to adventurous-template-tags.php because meta information output order is described in the latter php(adventurous-template-tags.php).

    So I first, prior to you advice, created a child theme of adventurous-template-tags.php in a bid to display meta information, which After all didn’t work out.

    What’s wrong with my idea??

    Kenta

    #84325
    Mahesh
    Participant

    Hi @Kenta,

    In WordPress, functions.php is the core function. Only the functions included in functions.php will be executed. Just to make you clear on the above issue, in Adventurous Pro, adventurous-template-tags.php is included in functions.php. It would be easy to work/find the functions in seperate small file than in a single large file.
    So if you prefer to follow the theme’s way of including, then you can put the function to adventurous-template-tags.php and then include it in child theme’s functions.php.

    Hope it makes you clear.
    Let me know if any problem or confusion.

    Regards,
    Mahesh

    #84940
    Kenta
    Participant

    Hello Mahesh,

    Thank your for your explanation that makes me clear.
    And everything is now working fine on my theme, anyway.

    Regards,
    Kenta

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Display tags in each excerpt on top page’ is closed to new replies.