BuddyBoss Home – Web Support Forums Themes BuddyBoss theme Add categories and tags to post meta

Tagged: , ,

Viewing 10 posts - 1 through 10 (of 10 total)
  • Question

    #33761
    @milena

    Hi – 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

    #33774

    Alyssa
    Participant
    @alyssa-buddyboss

    @milena here is the wordpress codex: http://codex.wordpress.org/Post_Meta_Data_Section simply add this to the page template in question.

    #33824
    @milena

    Hi @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_category

    I 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.

    #33834

    Alyssa
    Participant
    @alyssa-buddyboss

    @milena line 752 of theme-functions.php

    #33837
    @milena

    thank 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?

    #33841

    Alyssa
    Participant
    @alyssa-buddyboss

    @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;

    #33856
    @milena

    Hi @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 code

    function 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.

    #33866

    Alyssa
    Participant
    @alyssa-buddyboss

    @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.

    #33885
    @milena

    Hi @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?

    #33892

    Alyssa
    Participant
    @alyssa-buddyboss

    @milena I’ve never looked into writing code like that before. I think you’ll need to request that from WordPress support. This is custom coding you place it where you want it to be. You don’t need to edit custom.php

Viewing 10 posts - 1 through 10 (of 10 total)
  • The question ‘Add categories and tags to post meta’ is closed to new replies.