WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Whats the problem with this code? (4 posts)

  1. rikinhobr
    Member
    Posted 4 years ago #

    My code:

    <?php
    // turn off WordPress themes and include the WordPress core:
    define('WP_USE_THEMES', false);
    require($_SERVER['DOCUMENT_ROOT'] . '/blog/wp-blog-header.php');
    ?>
    <?php
    global $query_string;
    query_posts($query_string . "&order=DESC");
    while (have_posts()) : the_post();
    ?>
    <div style="width:500px;margin-bottom:20px;">
     <div style="width:500px;padding:2px;background:#336666;color:#FFF;font-size:14px;font-weight:800;">
      <?php the_title(); ?></div>
     <div style="width:500px;border-bottom:1px dashed #666;padding:2px;"></div>
     <div style="width:500px;padding:4px;text-align:justify;"><?php the_excerpt(); ?></div>
     <div style="width:500px;border-bottom:1px dashed #666;padding:2px;"></div>
      <div style="width:400px;">
       <div style="float:left;">Por <b><?php the_author(); ?></b> em <?php the_date('d/m/Y'); ?></div>
      </div>
    </div>
    <br /><br />
    <?php
    endwhile;
    ?>
    <?php posts_nav_link(' | ', 'Próxima Página', 'Página Anterior'); ?>

    I have 3 posts and I want to show only 2 with pagination...
    But the pagination doesnt appears... and just first post show the date, the next doesnt show...

    How can I fix it?

  2. rikinhobr
    Member
    Posted 4 years ago #

    please :\

  3. @mercime
    Volunteer Moderator
    Posted 4 years ago #

    You need to get $paged in your query
    Check out this article .
    Other ways:

    <?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=5'.'&paged='.$paged);
    while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>
  4. rikinhobr
    Member
    Posted 4 years ago #

    thank you very much!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags