Skip to:
Content
Pages
Categories
Search
Top
Bottom

new css classes to post

  • @crazy-nomce

    Participant

    How I can add new css classes to a (specific) post? It already exists or I should make a request for a new hook (if possible)?

Viewing 4 replies - 1 through 4 (of 4 total)
  • @crazy-nomce

    Participant

    Bump! Anyone knows?

    Thanks in advance.

    @mordauk

    Participant

    You can use the following three filters:

    bbp_get_forum_class
    bbp_get_topic_class
    bbp_get_reply_class

    Each of them function exactly like the core WordPress post_class filter: https://codex.wordpress.org/Function_Reference/post_class

    @djosephdesign

    Participant

    How do we implement this? I tried replacing

    <ul id="bbp-topic-<?php bbp_topic_id(); ?>" <?php bbp_topic_class(); ?>>

    with

    <ul id="bbp-topic-<?php bbp_topic_id(); ?>" <?php echo bbp_get_topic_class('test-class'); ?>>

    but the test class doesn’t show. I know I’m working with the right line of code because I can remove the class part altogether and see it removed from my site.

    @djosephdesign

    Participant

    I figured this out. I had to add this in my bbpress_functions:

    function my_topic_class($classes) {
    	$classes[] = 'test-class';
    	return $classes;
    }
    add_filter( 'bbp_get_topic_class','my_topic_class' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar