fred
fred

Reputation: 485

php formatting curly braces

I am having a problem with the code below. I am using get_query to fetch content from a custom post type called portfolio-type, on a page template called page-portfolio. The code is meant to find all new portfolio items and display them as a gallery. My problem is that every portfolio item appears as a child of the previous one. I think it has to do with how my curly braces are placed but I just can't seem to figure it out.

<?php
// The Query
$the_query = new WP_Query( $args );
?>

<?php
// The Loop
if ( $the_query->have_posts() ) {
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
?> 

        <?php
            $title= str_ireplace('"', '', trim(get_the_title()))
            $desc= str_ireplace('"', '', trim(get_the_content()));
        ?>      
        <div class="item">
        <?php $site= get_post_custom_values('projLink'); 
        if($site[0] != ""){
        ?>
        <div class="img">
            <a title="<?=$title?>: <?=$desc?>" href="<?=$site[0]?>"><?php the_post_thumbnail(); ?>
            </a>
        </div>                                          
        <?php }}}       
        else{ ?>
            <p><em>You need to post your link.</em></p>
        <?php } ?>
</div>   
<?php
  /* Restore original Post Data */
  phpwp_reset_postdata();
?>

You can see the result here you'll see the next item is 50% of the size of the last. My css is doing this but I should be able to use this css styling on this gallery without this issue happening.

Upvotes: 0

Views: 147

Answers (1)

Billy Bob
Billy Bob

Reputation: 242

<?php }}} else { should be just <?php } else {.

The other two braces should be further down, after the last </div>

Upvotes: 1

Related Questions