Support » Fixing WordPress » I can't get css float to work!

  • Hey!

    I created a custom template called “Projects”. It is listing the content that I typed for a project using the function the_content().
    I created a CSS class called “bibliography”. This is the code for my CSS class:

    .bibliography {
        background-color: #FFFFFF;
        color: #000000;
        border: 1px solid black;
        float: right;
        font-size: 10px;
        margin-bottom: 10px;
        margin-left: 10px;
        margin-top: 0;
        padding: 10px 5px 0 10px;
        width: 250px;

    I am using the CSS class “bibliography” to display some text that is related to the project. This related text is supposed to float on the side of the project text. However, the project text is only being displayed either above or below the “related text”. I have tried many approaches, but I can’t seem to fix the problem.

    Can anybody help me!?!

    Thank you!

Viewing 8 replies - 1 through 8 (of 8 total)
  • WPyogi


    Forum Moderator

    There’s no way to help with something like this without seeing the actual page live – can you post a link to it?

    Sure! Sorry about that.

    Sorry! Forgot to put link text lol

    Problem Page

    John Parris



    What’s the PHP function code look like? Also the template code? If it’s long, please use pastebin.

    This is the link to my Projects template file in pastebin:
    Project Template File

    This is the code for the the_content() function:

    function the_content($more_link_text = null, $stripteaser = false) {
    	$content = get_the_content($more_link_text, $stripteaser);
    	$content = apply_filters('the_content', $content);
    	$content = str_replace(']]>', ']]>', $content);
    	echo $content;

    In the template file, the code which pertains to the “Problem Page” is contained within the “else” code in lines 28-52.

    The function the_content() is located in wp-includes/post-template.php

    John Parris



    Sorry, I meant what does the function look like that creates the shortcode. I already know what the_content looks like in WP.

    Also, the placement of the shortcode is above the_content, so it’s always going to display outside of the post content. If you’re wanting the white “related” box inside the post (which I think you’re saying you do), you need to attach the function to the_content action filter. Something along these lines, but modified with your particular needs.

    function my_related_content( $content ) {
        $related = do_shortcode( '[shortcode_name]' );
        // Append the related box to the post content
        $content .= $related;
        // Return the content
        return $content;
    add_action( 'the_content', 'my_related_content' );


    In your style.css file, on line 444 you have this rule set up:

    h1,h2,h3,h4,h5,h6 {
        clear: both;

    Since “Introduction” on that page is an h2, it’s clearing the float right. Change that rule, or remove it completely and your problem is fixed.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘I can't get css float to work!’ is closed to new replies.