vapvarun icon

Add post categories in class

vapvarun | PRO | 02/08/22 07:34:49 AM UTC | 0 ⭐ | 1430 👁️ | Never ⏰ | []
PHP |

540 B

|

None

|

0 👍

/

0 👎

/**
 * Add post categories in class
 *
 * @param  mixed $output return html.
 * @return $output
 */
function reign_post_categories_callback( $output ) {
    global $post;
    $post_id       = $post->ID;
    $post_category = get_the_category( $post->ID );
    $cat_name      = '';
    foreach ( $post_category as $post_key => $post_val ) {
            $cat_name .= $post_val->slug . ' ';
    }
    $output = str_replace( 'cat-links', 'cat-links ' . $cat_name, $output );
    return $output;
}
add_filter( 'reign_post_categories', 'reign_post_categories_callback' );

Comments