WordPress.org

Ready to get started?Download WordPress

Forums

I can't get css float to work! (9 posts)

  1. tmeche87
    Member
    Posted 1 year ago #

    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!

  2. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

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

  3. tmeche87
    Member
    Posted 1 year ago #

    Sure! Sorry about that.

  4. tmeche87
    Member
    Posted 1 year ago #

    Sorry! Forgot to put link text lol

    Problem Page

  5. mindctrl
    Member
    Posted 1 year ago #

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

  6. tmeche87
    Member
    Posted 1 year ago #

    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;
    }
  7. tmeche87
    Member
    Posted 1 year ago #

    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

  8. mindctrl
    Member
    Posted 1 year ago #

    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' );
  9. wpismypuppet
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic