Help me display only 2 posts on home page wordpress... Thanks!!

Discussion in 'HTML & Website Design' started by locals, Jun 21, 2013.

  1. #1
    here is the code. Thanks for your help.

    
    <?php get_header(); ?>
     
    <?php
    if(get_option('aven_home') == "listing") { ?>   
    <?php include (TEMPLATEPATH . '/lib/listhome.php'); ?>
    <?php } else { ?>
    <div id="content">
     
    [COLOR=#ff0000]<?php[/COLOR]
    [COLOR=#ff0000]$temp = $wp_query;[/COLOR]
    [COLOR=#ff0000]$wp_query= null;[/COLOR]
    [COLOR=#ff0000]$wp_query = new WP_Query();[/COLOR]
    [COLOR=#ff0000]$wp_query->query('paged='.$paged);[/COLOR]
    [COLOR=#ff0000]?>[/COLOR]
    [COLOR=#ff0000]<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>[/COLOR]   
     
    <div class="post" id="post-<?php the_ID(); ?>">
     
    <div class="title">
      <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    </div>
    <div class="postmeta">
     
    </div>
     
    <div class="entry">
     
    <?php
    if ( has_post_thumbnail() ) { ?>
      <a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;h=150&amp;w=200&amp;zc=1" alt=""/></a>
    <?php } else { ?>
      <a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a>
    <?php } ?>
     
    <div class="clear"></div>
     
    [COLOR=#ff0000]<?php wpe_excerpt('wpe_excerptlength_index', ''); ?>[/COLOR]
     
     
    </div>
     
    </div>
     
    <?php endwhile; ?>
     
    <div class="clear"></div>
     
    <?php getpagenavi(); ?>
     
    <?php $wp_query = null; $wp_query = $temp;?>
       
    </div>
    <?php } ?>
    <?php get_sidebar(); ?>
     
    <?php get_footer(); ?>
    
    Code (markup):
     
    Solved! View solution.
    locals, Jun 21, 2013 IP
  2. ShinoRex

    ShinoRex Well-Known Member

    Messages:
    227
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    148
    #2
    Hi you can change it from wp-admin/options-reading.php

    Change the option 'Blog pages show at most' then see whether it is working or now...
     
    ShinoRex, Jun 21, 2013 IP
  3. #3
    Hey its simple you have to just change 1 line.

    Change:
    $wp_query->query('paged='.$paged);
    Code (markup):
    $wp_query->query('paged='.$paged.'&posts_per_page=2');
    Code (markup):
     
    iulian.pw, Jun 22, 2013 IP
  4. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #4
    Okay... so this worked for the homepage... but it also did it for all the other pages :| so that will not work. I thought it was an awesome easy fix. but that didn't work. sorry, any other help would be greatly appreciated. A also downloaded and tried the different posts per page plugin but since I think they are custom excerpts it is not working either
     
    locals, Jun 22, 2013 IP
  5. iulian.pw

    iulian.pw Active Member

    Messages:
    71
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    65
    #5
    Check into archive .php or category .php and apply the same change, another option will be to change the number in reading options inside the wordpress admin, and that is globally.
     
    iulian.pw, Jun 22, 2013 IP
  6. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #6
    This was as close as it could get, with out being perfect. it was in that same file, I was looking in the wrong .php file when I went back to check it.

    the correct code is
    $wp_query->query('post_type=listings'.'&paged='.$paged.'&posts_per_page=2');
    Code (markup):
     
    locals, Jun 22, 2013 IP