Want to Limit Displayed Ads on Classifieds Site to 4

Hello,

I am working with the Classipress theme for Wordpress, and I have been having trouble limiting the amount of suggested ads that display on the side. Can someone please help me edit this code so that it only displays the 4 most recent ads?

Thank you in advance!

[php]

<?php // show all ads but make sure the sticky featured ads don't show up first $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; query_posts( array('post_type' => APP_POST_TYPE, 'ignore_sticky_posts' => 1, 'paged' => $paged) ); global $wp_query; $total_pages = max( 1, absint( $wp_query->max_num_pages ) ); ?>

[/php]

I don’t believe you’ve posted the right code

dang, sorry about that. I am kinda a noob with php.

Here is the entire piece of code for that element (please let me know if I have left something out):

[php]

          <div class="clr"></div>

          <div class="undertab"><span class="big"><?php _e('Classified Ads','appthemes') ?> / <strong><span class="colour"><?php _e('Just Listed','appthemes') ?></span></strong></span></div>

            <?php
                // show all ads but make sure the sticky featured ads don't show up first
                $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                query_posts( array('post_type' => APP_POST_TYPE, 'ignore_sticky_posts' => 1, 'paged' => $paged) );
	    global $wp_query;
	    $total_pages = max( 1, absint( $wp_query->max_num_pages ) );
            ?>

            <?php

/**

  • Main loop for displaying ads
  • @package ClassiPress
  • @author AppThemes

*/
?>

<?php appthemes_before_loop(); ?> <?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>

    <?php appthemes_before_post(); ?>

    <div class="post-block-out">
    
        <div class="post-block">
    <?php appthemes_after_post_title(); ?>
      <div class="clr"></div>
            <div class="post-left">
 
                <?php if ( get_option('cp_ad_images') == 'yes' ) cp_ad_loop_thumbnail(); ?>
            
            </div>
            
    <h3><a href="<?php the_permalink(); ?>"><?php if ( mb_strlen( get_the_title() ) >= 75 ) echo mb_substr( get_the_title(), 0, 75 ).'...'; else the_title(); ?></a></h3>
   
                      <p class="post-desc"><?php $tcontent = strip_tags( get_the_content() ); if ( mb_strlen( $tcontent ) >= 165 ) echo mb_substr( $tcontent, 0, 165 ).'...'; else echo $tcontent; ?></p>

    
            <div class="<?php if ( get_option('cp_ad_images') == 'yes' ) echo 'post-right'; else echo 'post-right-no-img'; ?> <?php echo get_option('cp_ad_right_class'); ?>">
            
             
                
                <div class="clr"></div>
                
                <?php appthemes_before_post_content(); ?>
   <?php appthemes_after_post_content(); ?>
                <a href="<?php the_permalink(); ?>"><div class="view-listing">View Listing</div></a>
                
                
                  <?php appthemes_before_post_title(); ?>
                <div class="clr"></div>
    
            </div>
    
            <div class="clr"></div>
    
        </div><!-- /post-block -->
      
    </div><!-- /post-block-out -->   
    
    <?php appthemes_after_post(); ?>
    
<?php endwhile; ?>

<?php appthemes_after_endwhile(); ?>
<?php else: ?>
<?php appthemes_loop_else(); ?>
<?php endif; ?> <?php appthemes_after_loop(); ?> <?php wp_reset_query(); ?>
	<?php
	    if( $total_pages > 1 ){ ?>
		<div class="paging"><a href="<?php echo $post_type_url; ?>page/2/"> <?php _e( 'View More Ads', 'appthemes' ); ?> </a></div>
	    <?php } ?>

        </div><!-- /block1 -->

[/php]

Thank you very much for taking the time to look!

Sponsor our Newsletter | Privacy Policy | Terms of Service