Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-10-2013, 04:31 PM   PM User | #1
aiva286
New Coder

 
Join Date: Dec 2012
Posts: 11
Thanks: 3
Thanked 0 Times in 0 Posts
aiva286 is an unknown quantity at this point
Wordpress help 4 posts per row

Hello guys, can someone help fix this code ?
Where is problem ? Any ideas ? It doesn't show anything.
PHP Code:
<?php get_header(); ?>
<?php $counter
=1;global $query_string;query_posts($query_string.'&caller_get_posts=1&posts_per_page=9');if(have_posts()):while(have_posts()):the_post();if($counter==1):?>

<div class="post_row">
<div class="post_class"><?php elseif($counter==2): ?><div class="post_class"><?php elseif($counter==3): ?><div class="post_class"><?php elseif($counter=4): ?><div class="post_class"><?php endif; ?>

<a href="<?php the_permalink();?>"><?php the_post_thumbnail('default-thumb')?></a>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt() ?>
</div><!-- /.col -->

<?php if($counter==2): ?></div><!-- /.row cols2 -->
<?php if($counter==3): ?></div><!-- /.row cols2 -->
<?php if($counter==4): ?></div><!-- /.row cols2 -->
<?php $counter=0;endif;$counter++;endwhile;if($counter==4):?></div><!-- /.row cols2 --><?php endif;endif; ?>
<?php get_footer
(); ?>
aiva286 is offline   Reply With Quote
Old 01-10-2013, 04:47 PM   PM User | #2
TFlan
New Coder

 
Join Date: Dec 2012
Location: USA
Posts: 82
Thanks: 3
Thanked 17 Times in 17 Posts
TFlan is an unknown quantity at this point
My god that is some BUTT UGLY code...

Please for the love of god format your code in a readable fashion...

Try this:
This is assuming this code is within a function, since you are declaring a global variable...
PHP Code:
<?php
    get_header
();
    
$counter 1;
    global 
$query_string;
    
query_posts($query_string.'&caller_get_posts=1&posts_per_page=9');
    if(
have_posts()){
        while(
have_posts()){
            
the_post();
            if(
$counter == 1){ ?>
                <div class="post_row"> 
<?php    ?>
                    <div class="post_class">
                        <a href="<?php the_permalink();?>">
                            <?php the_post_thumbnail('default-thumb')?>
                        </a>
                        <h2>
                            <a href="<?php the_permalink(); ?>">
                                <?php the_title(); ?>
                            </a>
                        </h2> 
                        <?php the_excerpt() ?> 
                    </div>
<?php
            
if($counter == 4){ ?>
                </div>
<?php
                $counter 
0;
            }
            
$counter++;
        }
    }
    
get_footer();
?>
If this doesn't work it's because your code is literally crap (sorry for being blunt). Please post every line of code that this is related to, including the parent function/class/whatever

Last edited by TFlan; 01-10-2013 at 04:49 PM..
TFlan is offline   Reply With Quote
Users who have thanked TFlan for this post:
aiva286 (01-10-2013)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:52 AM.


Advertisement
Log in to turn off these ads.