BuddyBoss Home – Web › Support Forums › Themes › BuddyBoss theme › Add categories and tags to post meta
- This topic has 9 replies, 2 contibutors, and was last updated 10 years ago by Alyssa.
-
Question
December 2, 2014 at 6:54 am #33761@milenaHi – the theme doesn’t display categories and tags in the post meta and I need them both for the posts and my custom posts.
“posted in category:…” tagged : …”
How do I add this?
Thank you
Answers
December 2, 2014 at 12:58 pm #33774@alyssa-buddyboss
AlyssaParticipant@milena here is the wordpress codex: http://codex.wordpress.org/Post_Meta_Data_Section simply add this to the page template in question.
December 6, 2014 at 3:14 am #33824@milenaHi @tjchester,
thank you. I also found this reference in the forum, where you say:
https://www.buddyboss.com/support-forums/topic/home-articles-list-%E3%80%82how-to-add-article-categories/@play you will need to edit content.php and add something after this line (60):
<?php buddyboss_entry_meta(); ?>
You will need to create your own link and use the WP codex to make your link: http://codex.wordpress.org/Function_Reference/get_the_categoryI need to add the categories both inside the post and in the archive page. But how do I add it to the buddyboss_entry_meta ? (which template is responsible for that?) I tried pasting the code in several places inside content.php but it ends up above or under the buddyboss meta (date, author and leave a comment links). Style-wise these need to be the same.
December 6, 2014 at 8:49 am #33834December 6, 2014 at 9:34 am #33837@milenathank you.
i found this :
if ( ! function_exists( 'buddyboss_entry_meta' ) ) : /** * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. * * Create your own buddyboss_entry_meta() to override in a child theme. * * @since BuddyBoss 1.0 */ function buddyboss_entry_meta() { // Translators: used between list items, there is a space after the comma. $categories_list = get_the_category_list( __( ', ', 'buddyboss' ) ); // Translators: used between list items, there is a space after the comma. $tag_list = get_the_tag_list( '', __( ', ', 'buddyboss' ) ); $date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%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', 'buddyboss' ), get_the_author() ) ), get_the_author() ); // Translators: 3 is the date and 4 is the author's name. if ( $tag_list ) { $utility_text = __( '%3$s <span class="by-author"> by %4$s</span>', 'buddyboss' ); } elseif ( $categories_list ) { $utility_text = __( '%3$s <span class="by-author"> by %4$s</span>', 'buddyboss' ); } else { $utility_text = __( '%3$s <span class="by-author"> by %4$s</span>', 'buddyboss' ); } printf( $utility_text, $categories_list, $tag_list, $date, $author ); } endif;
how do I
Create my own buddyboss_entry_meta() to override in a child theme.
to include categories and tags too?
December 6, 2014 at 12:37 pm #33841@alyssa-buddyboss
AlyssaParticipant@milena in content.php change this:
<?php buddyboss_entry_meta(); ?>
to this:
<?php custom_buddyboss_entry_meta(); ?>
Then in functions.php add the buddyboss entry meta code with your newly added code but remember to rename the function to custom_
and remove this code from the above copied code:if ( ! function_exists( 'buddyboss_entry_meta' ) ) : /** * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. * * Create your own buddyboss_entry_meta() to override in a child theme. * * @since BuddyBoss 1.0 */
and the trailing
endif;
December 7, 2014 at 7:38 am #33856@milenaHi @tjchester.
I did everything you said.I don’t know what you mean by
Then in functions.php add the buddyboss entry meta code with your newly added code
This is the code
<p>Posted in <?php the_category(', '); ?></p>
I was usin in custom.php. I just added it above<?php buddyboss_entry_meta(); ?>
/Where shall I paste it withing this function?
also-
I am using a custom post type, and added a custom taxonomy for it, using this codefunction projects_taxonomy() { register_taxonomy( 'projects_categories', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces). 'projects', //post type name array( 'hierarchical' => true, 'label' => 'community', //Display name.............
How do I mention it in
<p>Posted in <?php the_category(', '); ?></p>
? and / or in the custom_buddyboss_meta function?thank you.
December 7, 2014 at 7:29 pm #33866@alyssa-buddyboss
AlyssaParticipant@milena add this code you your functions.php file:
function custom_buddyboss_entry_meta() { // Translators: used between list items, there is a space after the comma. $categories_list = get_the_category_list( __( ', ', 'buddyboss' ) ); // Translators: used between list items, there is a space after the comma. $tag_list = get_the_tag_list( '', __( ', ', 'buddyboss' ) ); $date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%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', 'buddyboss' ), get_the_author() ) ), get_the_author() ); // Translators: 3 is the date and 4 is the author's name. if ( $tag_list ) { $utility_text = __( '%3$s <span class="by-author"> by %4$s</span>', 'buddyboss' ); } elseif ( $categories_list ) { $utility_text = __( '%3$s <span class="by-author"> by %4$s</span>', 'buddyboss' ); } else { $utility_text = __( '%3$s <span class="by-author"> by %4$s</span>', 'buddyboss' ); } printf( $utility_text, $categories_list, $tag_list, $date, $author ); }
NOTE the only difference is the changed function name. You will need to add your code within the function, where is up to you where ever you want it to show up. I will warn you about using a p tag that it may create line breaks, you may need to make a custom class a use float left or right to get it to align where you want properly or try without the p tag.
December 9, 2014 at 8:34 am #33885@milenaHi @tjchester,
how do I write
posted on (this date) by (this author) in (this category). add comments
I don’t understand where shall I paste the code inside the custom function, and what to do next. Edit custom.php?
December 9, 2014 at 4:50 pm #33892
- The question ‘Add categories and tags to post meta’ is closed to new replies.