Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I enqueue the custom css?


  • failxontour
    Participant

    @felixbauerschaefer

    Hey so I’m trying to enqueue custom CSS for bbPress v2.6.4 on the WP 5.4.1 clan website running a WP Twenty Twenty-child theme.

    This is what my functions.php currently looks like

    <?php
    /**
    * Child theme stylesheet einbinden in Abhängigkeit vom Original-Stylesheet
    */
    add_action( 'wp_enqueue_scripts', 'child_theme_styles' );
    function child_theme_styles() {
      wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
      wp_enqueue_style( 'child-theme-css', get_stylesheet_directory_uri() .'/style.css' , array('parent-style'));
      wp_enqueue_style( 'child-theme-css', get_stylesheet_directory_uri() .'/css/bbpress.css', array());
    }
    ?>
    

    And this is how my bbpress.css looks like.

    
    #bbp-forum-info,
    #bbp-forum-topic-count,
    #bbp-forum-reply-count,
    #bbp-forum-freshness {
      color: #232323;
    }
    #bbpress-forums {
      background: transparent;
      clear: both;
      margin-bottom: 20px;
      overflow: hidden;
      font-size: 1.75rem;
      color: #232323;
    }
    

    The changes I applied in the bbpress.css won’t update the bbpress CSS on the above mentioned site. So their must be something wrong with my functions.php but I can’t yet put my finger on it how to load it properly as I’m pretty new when it comes to WordPress. I wanna append these changes globally to all parts of bbPress forum.

    Can someone tell me to if and what i need to specify inside the arrray() call for the bbpress.css to load properly? Or hint me towards what’s wrong here.

Viewing 6 replies - 1 through 6 (of 6 total)

  • Robin W
    Moderator

    @robin-w

    if that second part is all you are after, then add it to the custom css bit of your theme, or use

    Simple Custom CSS


    failxontour
    Participant

    @felixbauerschaefer

    I know i could put these changes inside the style.css simple custom css will do the job and load another css file on top for these changes which could be applicable for my use case.

    But I wanna have the files all in the child-theme in case someone else wants to make design adjustments that their visible and accessible on first sight.

    Access to a FTP-Server is given and for adjustments on-top of WordPress and their is a Theme-Editor already embedded into WordPress so that seems to be a bit counter-intuitive. As it might confuse admins & content-editors later on to where they input their changes.

    CSS is simple to learn and as this is gonna be pure CSS not LESS/SASS i figure it’s best if I had it in a seperate file to view for people.


    failxontour
    Participant

    @felixbauerschaefer

    Wouldn’t it be the logical step now to look check inside the DB for which arrays bpress uses so i could append the css file now?


    Robin W
    Moderator

    @robin-w

    you can only enqueue a style name once, so suggest you rename the second child one eg

    wp_enqueue_style( 'child-theme-css', get_stylesheet_directory_uri() .'/style.css' , array('parent-style'));
      wp_enqueue_style( 'child-theme-bbpress-css', get_stylesheet_directory_uri() .'/css/bbpress.css', array());

    that might be the problem, if not, it certainly isn’t helping


    failxontour
    Participant

    @felixbauerschaefer

    It worked thanks! Sure wouldn’t have suspected that for the future i guess I should use the ispage() option to load it appropiately only for bbpress.
    forum-css


    Robin W
    Moderator

    @robin-w

    unless you are running a very highly spec’d server and your users can’t wait another nano second, I would not worry about only loading on bbpress pages.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar