Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So I have customized a few plugins before, but never developed one from scratch. One thing that I have struggled with is structuring my functions. I found the following snippet and wonder how YOU would structure it and why?

<?php wp_reset_query(); ?>

<?php
$args = array(
'post_type'      => 'page',
'posts_per_page' => -1,
'post_parent'    => 94,
'order'          => 'DESC',
'orderby'        => 'ID',
);
$wp_query = new WP_Query( $args );

if ( $wp_query->have_posts() ) : ?>

<div class="row-fluid row-portfolio">

<?php $count=0; ?>    
    <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

<div class="span4">
<div class="portfolio-thumb">

        <a href="<?php the_permalink(); ?>">
    <?php echo get_the_post_thumbnail( $post_id, $attr ); ?>
    <span class="portfolio-thumb-title"><p>
            <?php the_title(); ?></p></span></a>    

</div>        
</div>

<?php $count++; ?>

<?php if ($count==3 ||$wp_query->found_posts==0) :

    echo '</div><div class="row-fluid row-portfolio">';

?>

<?php $count=0; ?>

<?php endif; ?>
<?php endwhile; ?>

<?php else : ?>                
<h3>Sorry but there are no portfolio items.</h3>
<?php endif; ?>

<?php wp_reset_query(); ?>
</div>
share|improve this question
3  
Have you seen this? –  toscho Sep 4 '13 at 20:42
1  
It's just a query, I don't think you'd gain anything from abstracting that since it seems tied to the theme. –  elclanrs Sep 4 '13 at 20:47
    
I don´t think it is really tied to a theme, its only dependent on the bootstrap css or am I wrong? –  StenW Sep 4 '13 at 21:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.