Skip to:

Custom Backgrounds per Topic

  • akapope


    Hey BBPress!

    I was wandering if ya’ll can help me out with this. So I have my theme styled so that each Forum gets its own background through the style.css file using the following lines:

    .postid-17 {
    background: #000000 url( center top no-repeat fixed;

    where postid-17 is the correlating WordPress post associated with the Forum.

    The problem now is that when you visit a Topic within the Forum, the background goes back to the default image :/

    I am thinking that there should be a code to pull the topics Parent Forum “postid” and then force the background to the topic.

    I hope that makes sense. I can dig through code, but I am not so skilled with writing my own yet.

    Thanks in advance for your help.

    WordPress and BBPress are running the latest versions:

    Site – htp://
    Theme – Twentytwelve

Viewing 1 replies (of 1 total)

  • akapope


    Thanks for the help guys 🙂

    I figured it out, but thought I would update in case anyone comes across this as well. I admit this may not be the best solution; however it is working and I am happy.

    In the /wp-includes/post-template.php file, at line 427 I edited it to this:

    if ( is_single() ) {
    		$post_id = $wp_query->get_queried_object_id();
    		$post = $wp_query->get_queried_object();
    		$parent_id = get_post($post_id)->post_parent;
    		$classes[] = 'single';
    		if ( isset( $post->post_type ) ) {
    			$classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id);
    			$classes[] = 'postid-' . $post_id;
    			$classes[] = 'parentforum-' . $parent_id;

    Where $parent_id = get_post($post_id)->post_parent;
    And $classes[] = 'parentforum-' .$parent_id;

    Are the additions.

    Then in the themes /style.css file I added something like:

    .postid-17 {
    background: #000000 url( center top no-repeat fixed;

    Boom Baby!

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