WordPress.org

Forums

[resolved] I am having server errors, so I'm wondering if this code is OK? (3 posts)

  1. wpmhweb
    Member
    Posted 2 years ago #

    Hello,

    I am getting random blank pages and sometimes Internal server error with WordPress, could anyone tell me if the following code is OK?

    Thanks,

    <?php
        $recentPosts = new WP_Query();
        $recentPosts->query('showposts=2')
    	;?>
    
    <?php $count = 0; ?>
    
    <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
       <!-- do some stuff here -->
    
                    <?php $count++; ?>
    
                    <?php if ($count == 1) : ?>
    
    	<div id="post-<?php the_ID(); ?>" class="onegrd">
    
                <a href="<?php the_permalink() ?>" rel="bookmark" class="big-link"></a>
    
                <div class="feature-meta">
    
        <h2><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></h2>
        <p style="color:#fff; line-height: 15px;"><?php custom_excerpt(250); ?></p>
    
        </div>
    
                    <div class="image-window shadowbox" style="width: 339px; height: 288px;">
                    <a style="position: absolute; width: 684px; height: 100%; overflow:hidden; left: -150px;" href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail('large'); ?></a>
    
    						</div>
    
        	</div>
    
            <?php elseif ($count == 2) : ?>
    
            <div iid="post-<?php the_ID(); ?>" class="twogrd featured2">
    
            			<a href="<?php the_permalink() ?>" rel="bookmark" class="big-link"></a>
    
                <div class="feature-meta-smaller">
    
        <h2><a style="line-height: 28px!important; font-size:30px!important;" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
        <?php /*?><p style="color:#fff; line-height: 15px;"><?php custom_excerpt(140); ?></p><?php */?>
    
        </div>
    
                    <div class="image-window shadowbox">
                    <a style="position: absolute; overflow:hidden; width: 150%; height: auto;" href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail('large'); ?></a>
    
    						</div>
    
            		</div>
     <?php endif; ?>
    
                   <?php endwhile; ?>

    What I am trying to do here is to customize each post differently in the in a custom homepage.

    Thanks,

  2. Andrew
    Forum moderator
    Posted 2 years ago #

    That code looks okay.
    If you're trying to determine errors, try looking into your apache error logs.

  3. wpmhweb
    Member
    Posted 2 years ago #

    Thank you for your reply!

Topic Closed

This topic has been closed to new replies.

About this Topic