Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter durocketuk

    (@durocketuk)

    Hello,

    I have made some progress. I have designed 2 custom widgets to display the text of 2 specific custom fields of my article in a custom sidebar (created with the custom sidebar plugin)
    http://www.durocketdescarottes.fr/2016/08/22/edimbourg-16-20-juillet-2016

    “Du Rock” is my first widget, “Des carottes” is my second widget

    This should allow me to control the display of each widget independently. However I am unable to control the appearance of these with CSS. I’d like to shift both of them below the title, increase separation between them (i.e., increase top margin of second widget), and have a different background color for each.

    I have inspected my page with Firebug but neither

    .widget_du_rock_widget .widget {
      background-color: rgba(51, 153, 255, 0.1) !important;
    	margin-top: 110px !important;
    }

    (which is supposed to affect only top widget)

    nor

    .tc-sidebar .left {
      background-color: rgba(51, 153, 255, 0.1);
    	margin-top: 110px;
    }

    (which is supposed to affect the whole sidebar), works.

    What am I missing ?

    Thanks in advance for your input

    Hi,
    It does affect the top margin. I can see it on your site.

    Alternately, you can also include an id and use the id to style your widget.

    For instance, change your code to,

    add_action( '__before_left_sidebar', 'du_rock_box' );
    function du_rock_box() {
    if ( is_singular( 'post') ) {
    $rock = get_post_meta( get_the_ID(), 'du_rock', true );
    if( ! empty( $rock ) ) {
        echo '<div id="my_rock" class="widget_area">'. '<p style="font-size:24px; color:#0000FF;">du Rock</p>' .'</div>';
    		echo '<div class="widget_area">'. $rock .'</div>';
        }
      }
    }

    and then style it like below.

    #my_rock {
       margin-top: 110px;
    }
    Thread Starter durocketuk

    (@durocketuk)

    Thank you Menaka,

    Following your adice, I included an ID in the php code to be able to style it independently.

    If your issue is resolved, will you mark this post as resolved?

    Thread Starter durocketuk

    (@durocketuk)

    Yes, thanks,

    Benjamin

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

The topic ‘Multiple post-specific sidebars’ is closed to new replies.