Skip to:
Content
Pages
Categories
Search
Top
Bottom

Don’t Inherit BP-Default CSS Child Theme


  • InHouse
    Member

    @inhouse

    Hi,

    I’ve created a child theme using the BP Codex and was able to activate it correctly. I could override the default CSS but I wanted to have a blank slate. I used the PHP code in a new functions.php file. Now I have no styles at all. I have pasted the code below. Is there something I’m supposed to edit in this code or is it supposed to be as is with of course the required PHP wrap?

    `if ( !function_exists( ‘bp_dtheme_enqueue_styles’ ) ) :
    function bp_dtheme_enqueue_styles() {}
    endif;`

    I know my theme is working otherwise because I have copied footer and header.php and made modifications to it that are visible.

    Thanks for the help.

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

  • InHouse
    Member

    @inhouse

    Also, I wondered if I made a mistake in the header of my stylesheet. Do I need to have an absolute path to the stylesheet? My theme URI is currently written as “http://www.mydomain.com/wp-content/themes/theme-name”. Is this what is tripping me up? I assume not since the stylesheet was recognized prior to creating the functions.php file. I’m very confused.

    `/*
    Theme Name: BuddyPress Dusk
    Theme URI: http://example.org/themes/dusk/
    Description: Dark theme for BuddyPress.
    Version: 1.0
    Author: John Doe
    Author URI: http://example.org/
    Template: bp-default
    Tags: buddypress, two-column, grey, dark
    */`


    Boone Gorges
    Keymaster

    @boonebgorges

    If you’re going to override bp_dtheme_enqueue_styles(), then you’ll need to enqueue your own stylesheet. ie

    `if ( !function_exists( ‘bp_dtheme_enqueue_styles’ ) ) :
    function bp_dtheme_enqueue_styles() {
    wp_enqueue_style( ‘my-stylesheet’, WP_CONTENT_URL . ‘/themes/my-theme/style.css’ );
    }
    endif;`


    InHouse
    Member

    @inhouse

    Thanks for replying @boonebgorges. I’ve enjoyed some of your talks via wordpress.tv. I wish that info was included in the Codex. At least a mention that just because my theme was activated doesn’t mean my stylesheet was automatically linked. Maybe that’s obvious to others? I dunno.

    I changed the path to my theme “/themes/my-theme.style.css” but it still doesn’t seem to have worked. Do I need to change anything else in the code you provided? “my-stylesheet” for instance? I’m never worked with a child theme before. Thanks again.

    Am having this problem aswell, i just tried solution provided by @Boone, but still same thing. i have been having the problem for a while which makes me switch back to bp 1.2


    @mercime
    Keymaster

    @mercime


    InHouse
    Member

    @inhouse

    Thanks @mercime, I’ve already been staring at that page for over an hour. I can’t figure out what I’m doing wrong. I’ve tried every variation of the code I can think to try. Seneca County is the name of my custom child theme. What am I missing? The Codex doesn’t really explain how to modify the example. If you’ve never done it before, I don’t know how you’d look at the example and just figure it out. Please help :)

    `if ( !function_exists( ‘bp_dtheme_enqueue_styles’ ) ) :
    function bp_dtheme_enqueue_styles() {
    wp_enqueue_style( ‘seneca-county’, get_template_directory_uri() . ‘/themes/seneca-county/style.css’ );
    }
    endif;`

    `if ( !function_exists( ‘bp_dtheme_enqueue_styles’ ) ) :
    function bp_dtheme_enqueue_styles() {
    wp_enqueue_style( ‘my-stylesheet’, WP_CONTENT_URL . ‘/themes/my-theme/style.css’ );
    }
    endif;`


    @mercime
    Keymaster

    @mercime

    – `get_template_directory_uri()` should be `get_stylesheet_directory_uri()` for your child theme
    – after the template tag above `/themes/seneca-county/style.css’ should just be ‘style.css’

    therefore:
    `if ( !function_exists( ‘bp_dtheme_enqueue_styles’ ) ) :
    function bp_dtheme_enqueue_styles() {
    // Bump this when changes are made to bust cache
    $version = ‘20111102’;
    // Register main stylesheet
    wp_register_style( ‘seneca-county’, get_stylesheet_directory_uri() . ‘/style.css’, array(), $version );
    // Enqueue main stylesheet
    wp_enqueue_style( ‘seneca-county’ );
    }
    add_action( ‘wp_print_styles’, ‘bp_dtheme_enqueue_styles’ );
    endif;`


    InHouse
    Member

    @inhouse

    Wow, that is a far cry from what was posted in the Codex and what @boonebgorges posted. I still don’t understand why or how this works, but it works! Again, I wish Codex was written more in depth so new people can actually learn it. Thanks so much for your help @mercime. I appreciate it.


    Boone Gorges
    Keymaster

    @boonebgorges

    > I wish Codex was written more in depth

    The Codex is written and maintained by volunteers. As @mercime was so kind as to jump in and explain what’s up, maybe you could be so kind as to edit the relevant page :)

    Also, some of these issues have been in flux through the end of the 1.5 dev cycle. In any case, what @mercime wrote is essentially the same thing that I wrote – you must have been writing the paths wrong.

    Thanks for your patience!


    @mercime
    Keymaster

    @mercime

    @inhouse as @boonebgorges noted above, what I posted was essentially the same thing, and I learned it all from @boonebgorges and other BuddyPress Devs :-)

    10-4 @boonebgorges will tackle the update of relevant pages in BP Codex by this weekend latest :-)


    InHouse
    Member

    @inhouse

    @boonebgorges and @mercime I owe all I know (very little) to Codex and forum threads. I have enjoyed learning and greatly appreciate the work of all the volunteers. I was just saying in general, Codex can be hard to follow for a noob but I think that comes with trying to do more than I can before learning more basic WP skills. Thanks again for your help!


    jujumarquez23
    Member

    @jujumarquez23

    I’m so confused myself….i created the child theme and created and inherited all the templates. But then I try to copy and paste the header.php or functions.php file into my child theme and an error shows up saying I can’t modify that file….am I doing something wrong….Please help this is for my thesis project and I don’t want to mess it up


    jujumarquez23
    Member

    @jujumarquez23

    I’m also trying to change things with my css style sheet but nothing seems to work


    bollocks187
    Member

    @bollocks187

    All, can we start this again for my clarity. This is what I do to get started playing with Buddypress.

    1) Create under WP themes a folder e.g. bbexample

    2) Go to WP plugins find, buddypress folder, bp_themes folder and then select the bp_default folder

    3) Select and copy ALL the contents in the bp_default folder. The Codex talks about certain things but I copy everything, so I can play with the PHP files in some of the subfolders.

    4) Go back to bbexample theme folder under WP content (which is currently empty)

    5) Paste everything you copied in 3)

    6) Now you have a populated theme with lots of stuff in the folder. Yeah baby !

    7) First open the style.css in bbexample

    8) Replace ALL the contents with the following:

    /*
    Theme Name: bbexample
    Theme URI: http://blahblah
    Description: My theme for BuddyPress.
    Version: 1.0
    Author: PJ Bollocks
    Author URI: http://blahblah.org/
    Template: bp-default
    Tags: buddypress, two-column, grey, dark
    */

    /***
    * The following imported file is my personal copy of the bp_default style sheet and is located in my theme area
    */
    @import url( _inc/css/default.css );

    /**
    * Any other additional CSS style information can be placed below:
    **/

    8) Save the style.css

    9) Open the functions.php file to load up your theme styles and essentially kick out the bp_default theme.

    10) Replace the contents inside the php delimeters with the following as stated by previous BB players:

    if ( !function_exists( ‘bp_dtheme_enqueue_styles’ ) ) :
    function bp_dtheme_enqueue_styles() {
    // Bump this when changes are made to bust cache
    $version = ‘20111102’;
    // Register main stylesheet
    wp_register_style( ‘bbexample’, get_stylesheet_directory_uri() . ‘/style.css’, array(), $version );
    // Enqueue main stylesheet
    wp_enqueue_style( ‘bbexample’ );
    }
    add_action( ‘wp_print_styles’, ‘bp_dtheme_enqueue_styles’ );
    endif;

    11) Now you have a fully functional BuddyPress compatible theme (based on bb_default), but this is now yours to edit and play with as you see fit.

    12) Load the theme and check it out. It looks and performs identical to bp-default and it should since it is your copy.

    13) To Edit the CSS then you open the file under bbexample/_inc/default.css

    14) You can “Modify” the Theme layout, adding widgets etc, changing the page layouts and modifying some of the PHP display contents by finding the right file under bbexample folders.

    Warning: disclaimer: I am a hack and Luv it

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Don’t Inherit BP-Default CSS Child Theme’ is closed to new replies.
Skip to toolbar