Reply To: Portfolio problem

Homepage Community Forums Epik Theme Support Portfolio problem Reply To: Portfolio problem

#8091
Wes
Moderator

    This will be fixed in the new update 1.3.1

    Basically there needs to be a div that “clears” everything after the 4th post, so that the 5th post starts on a new line in front (towards the left). Without it, it shows up next to the last post with the most height. The code in the portfolio file to add “clear: both” worked with Genesis before, but when the Genesis 2.0 update was released we had to come up with a new way.

    To fix it, look for this in your page_portfolio.php file –

    // Clear float using genesis_custom_loop() $loop_counter variable
    // Outputs clearing div after every 4 posts
    // $loop_counter is incremented after this function is run
    add_action( 'genesis_after_post', 'portfolio_after_post' );
    function portfolio_after_post() {
        global $loop_counter;
        
        if ( $loop_counter == 3 ) {
            $loop_counter = -1;
            echo '<div class="clear"></div>';
        }
    }

    Then replace that code with this –

    // Outputs clearing div after every 4 posts
    add_action( 'genesis_after_entry', 'portfolio_after_post' );
    function portfolio_after_post() {
        
    	global $wp_query;
        
        // Assumes 4 posts per row
    	$end_row = ( $wp_query->current_post + 1 ) / 4;
            
    	if ( ctype_digit( (string) $end_row ) ) {
    		echo '<div class="clear"></div>';	
    	}
    }

    Then you’ll need to add .clear to your css like this –

    .clear {
    	clear: both;
    }

    That should fix it.