- This topic has 4 replies, 2 voices, and was last updated 8 years, 7 months ago by Kenta.
-
AuthorPosts
-
January 30, 2016 at 2:33 pm #84143KentaParticipant
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
January 31, 2016 at 11:07 am #84216MaheshParticipantHi @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,
MaheshFebruary 1, 2016 at 12:58 pm #84314KentaParticipantHi 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
February 1, 2016 at 1:57 pm #84325MaheshParticipantHi @Kenta,
In WordPress,
functions.php
is the core function. Only the functions included infunctions.php
will be executed. Just to make you clear on the above issue, in Adventurous Pro,adventurous-template-tags.php
is included infunctions.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 toadventurous-template-tags.php
and then include it in child theme’sfunctions.php
.Hope it makes you clear.
Let me know if any problem or confusion.Regards,
MaheshFebruary 8, 2016 at 12:54 pm #84940KentaParticipantHello Mahesh,
Thank your for your explanation that makes me clear.
And everything is now working fine on my theme, anyway.Regards,
Kenta -
AuthorPosts
- The topic ‘Display tags in each excerpt on top page’ is closed to new replies.