• Resolved thebookreporter

    (@thebookreporter)


    I just added a new post and my foreground color (white) has disappeared from my posts and several of my pages. On those pages where the white color has not disappeared, I have lost my sidebar. The only page/post of mine that is not affected is my home page. I have made changes to my CSS, but all of them have been made to my child theme and not the main Twenty Eleven template.

    Here is my home page: http://newbooksinbrief.com/

    Here is a page of mine that has lost its foreground color: http://newbooksinbrief.com/archived-articles/

    Here is a page of mine that has lost its sidebar: http://newbooksinbrief.com/about/

    What the heck is going on here? Please help!

Viewing 15 replies - 1 through 15 (of 18 total)
  • Try and activate the Twenty Eleven theme and see if you still have the issues. If you don’t then you know the issues are in your child theme.

    Thread Starter thebookreporter

    (@thebookreporter)

    Thanks for your response. The problem is definitely in my child theme. Any ideas on how to fix it?

    That’s not an easy question without looking at the code. You may want to look at the last edits that were made to your child theme and try to work backwards to find where the culprit is.

    Thread Starter thebookreporter

    (@thebookreporter)

    O.k. I’ve discovered the culprit. It has to do with my sidebar. I’ve imported my sidebar into all of my pages by way of adding

    <?php get_sidebar(); ?>

    above the

    <?php get_footer(); ?>

    in the Single Post file of my child theme (single.php). And also adding the following code into the Theme Functions file of my child theme (functions.php), which I think makes room for the added sidebar content:

    <?php
    add_filter('body_class', 'blacklist_body_class', 20, 2);
    function blacklist_body_class($wp_classes, $extra_classes) {
    if( is_single() || is_page() ) :
    // List of the classes to remove from the WP generated classes
    $blacklist = array('singular');
    // Filter the body classes
      foreach( $blacklist as $val ) {
        if (!in_array($val, $wp_classes)) : continue;
        else:
          foreach($wp_classes as $key => $value) {
          if ($value == $val) unset($wp_classes[$key]);
          }
        endif;
      }
    endif;   // Add the extra classes back untouched
    return array_merge($wp_classes, (array) $extra_classes);
    }

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    I feel like the problem has to be stemming from the functions.php modification I made, but I don’t know how. Any suggestions?

    One way you can check is to remove the code from the functions.php file and see if you still have the issue. This could be just for testing purposes. Once you’ve identified the problematic code, let us know what you are trying to do with it. What is the function of the added code?

    Thread Starter thebookreporter

    (@thebookreporter)

    When I remove the 2 codes the problem disappears. However, what the 2 codes were for was to be able to add my sidebar to my posts. I would still like my sidebar on my posts, so I still need to figure out how to do this without reintroducing the offending code.

    The strange thing is that even with the 2 codes removed, when I try to change one of my pages from default mode to sidebar mode, the problem reappears on that page and I lose the white color of my foreground (while gaining the sidebar). This makes me think that the problem goes deeper than just the 2 codes that I’ve removed, but this is just a guess. Thanks a lot for your help btw, any ideas?

    You mention 2 codes but you posted one set of code. What is the other code you are speaking of? Are you referring to <?php get_sidebar(); ?> ? Keep that in and just removed the code you posted from your functions php file. The get_sidebar() code just inserts the sidebar at that point in the theme.

    Thread Starter thebookreporter

    (@thebookreporter)

    O.k. When I add just the <?php get_sidebar(); ?> code to my single.php I do get the sidebar on my posts, but the proper margins get thrown way off. I have modified my margins in my CSS using the following code:

    .left-sidebar #primary {
    float: right;
    margin: 0 0 0 -30.4%; /* increased left margin 4% from -26.4% to -30.4% */
    width: 100%;
    }
    .left-sidebar #content {
    margin: 0 5% 0 38%; /* increased right margin 4% from 34* to 38% */
    width: 58.4%;
    }
    .left-sidebar #secondary {
    float: left;
    margin-left: 5%;
    margin-right: 0;
    margin-top: 20px;
    width: 22.8%; /* increased sidebar width 4% from 18.8% to 22.8% */
    }

    Now something really bad happened, though. My site has gone completely blank. When I try to remove the last change I made (reintroducing the <?php get_sidebar(); ?> into my single.php) the site remains blank. Things are quite bad here…

    See if you can remove the theme using ftp. If you can, it most likely will revert to the default theme. If that works, reupload your theme and see if you still have those issues.

    Thread Starter thebookreporter

    (@thebookreporter)

    O.k., so my site is alive again (thank you). Now the only problem I have is with the sidebar. As I mentioned, when I try to add the <?php get_sidebar(); ?> code to my single.php (just above the <?php get_footer(); ?>) the sidebar shows up on my posts but the margins get thrown off and I lose my white foreground color.

    For the background color, try this:

    .left-sidebar #primary {
    float: right;
    margin: 0 0 0 -30.4%;
    width: 100%;
    background-color: #fff;
    }
    Thread Starter thebookreporter

    (@thebookreporter)

    O.k. adding the background-color: #fff; worked to preserve the color of my background, but the margins are way off. When I go back into my functions.php and add my

    <?php
    add_filter(‘body_class’, ‘blacklist_body_class’, 20, 2);
    function blacklist_body_class($wp_classes, $extra_classes) {
    if( is_single() || is_page() ) :
    // List of the classes to remove from the WP generated classes
    $blacklist = array(‘singular’);
    // Filter the body classes
    foreach( $blacklist as $val ) {
    if (!in_array($val, $wp_classes)) : continue;
    else:
    foreach($wp_classes as $key => $value) {
    if ($value == $val) unset($wp_classes[$key]);
    }
    endif;
    }
    endif; // Add the extra classes back untouched
    return array_merge($wp_classes, (array) $extra_classes);
    }

    the margins return to normal but I lose my background color! Sorry about this. It’s a thorny problem.

    So, the code that you posted is there just to create the margins? What other purpose does it serve? If it is just to create the margins, you can accomplish that using css and not add the code since it appears that the code is removing some css classes.

    Thread Starter thebookreporter

    (@thebookreporter)

    Yes, that code is just there to make sure the margins in my posts conforms to the margins of my pages. I needed to add it after I added the sidebar to my posts because otherwise the margins in my posts were way off. This is because I had changed the margins of my pages a bit from the template (on my child theme). I did this by adding the following code to my css:

    .left-sidebar #primary {
    float: right;
    margin: 0 0 0 -30.4%; /* increased left margin 4% from -26.4% to -30.4% */
    width: 100%;
    }
    .left-sidebar #content {
    margin: 0 5% 0 38%; /* increased right margin 4% from 34* to 38% */
    width: 58.4%;
    }
    .left-sidebar #secondary {
    float: left;
    margin-left: 5%;
    margin-right: 0;
    margin-top: 20px;
    width: 22.8%; /* increased sidebar width 4% from 18.8% to 22.8% */
    }

    I have since amended this code in my css to include the color code that you provided. I’m not sure how I would have to change my css in order to make sure the margins in my posts matches the margins of my pages?

    Do you have google chrome downloaded as a browser on your computer? If so, you can hit f12 to bring up the dev tools. From here you can inspect an element and it will show you the html along with the css and you edit the code on the fly to show you how it may look. Once you know, you can then edit the actual code and then upload it via ftp or the editor in wordpress. I took a leap with the difficulty of this but if you feel you can give it a shot, do so.

    Other then that, the issue is most likely in the code that you pasted. The margins can be tweaked to get the desired results. If anything, change each one and see what effect it has. It will be a little slower for you but it is doable.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Foreground color lost/sidebar lost’ is closed to new replies.