Support » Fixing WordPress » Ammunity to all query_posts&pagination 'fixes' in 3,2,1?

  • require('./wp-load.php');
    global $query_string;
    query_posts($query_string.'&orderby=date&order=DESC');
    while ( have_posts() ) : the_post();
    echo '<div class="pwrap">';
    echo '<div class="ptitle">'.the_title('','',false).'</div>';
    echo '<div class="pcontent">'.get_the_excerpt().'</div>';
    echo '<div class="pfooter">'.get_the_date().' '.get_the_time().'</div>';
    echo '</div>';
    endwhile;
    echo '<div style="width:100%;text-align:center;">';
    posts_nav_link(' · ', 'previous page', 'next page');
    echo '</div>';
    wp_reset_query();
    ?>

    results in same posts on all pages and only one link showing on both.

    require('./wp-load.php');
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('&orderby=date&order=DESC&paged='.$paged);
    while ( have_posts() ) : the_post();
    echo '<div class="pwrap">';
    echo '<div class="ptitle">'.the_title('','',false).'</div>';
    echo '<div class="pcontent">'.get_the_excerpt().'</div>';
    echo '<div class="pfooter">'.get_the_date().' '.get_the_time().'</div>';
    echo '</div>';
    endwhile;
    echo '<div style="width:100%;text-align:center;">';
    posts_nav_link(' · ', 'previous page', 'next page');
    echo '</div>';
    wp_reset_query();
    ?>

    results in same posts on multiple pages also only one link showing.

    require('./wp-load.php');
    query_posts('&orderby=date&order=DESC&paged='.$_REQUEST['paged']);
    while ( have_posts() ) : the_post();
    echo '<div class="pwrap">';
    echo '<div class="ptitle">'.the_title('','',false).'</div>';
    echo '<div class="pcontent">'.get_the_excerpt().'</div>';
    echo '<div class="pfooter">'.get_the_date().' '.get_the_time().'</div>';
    echo '</div>';
    endwhile;
    echo '<div style="width:100%;text-align:center;">';
    posts_nav_link(' · ', 'previous page', 'next page');
    echo '</div>';
    wp_reset_query();
    ?>

    results in accurate posts display, but only one link shows on both pages and both go to the last&own page on both.

    I’m embedding wordpress in a layout and just need pagination to work for indexing blog posts by date. Non of the published ‘fixes’ work on 3.2.1. Needing a solution for an embedding scenario.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tokiojoe

    (@tokiojoe)

    bump

    any assistance is appreciated. I bumped cause all the posts that buried this one overnight have solutions in the top-10 results on google index.

    Thread Starter tokiojoe

    (@tokiojoe)

    Since support seems to be next to non-existent for real issues and ‘fixes’ on the net are dated and don’t work: Here is a hacky method that is guaranteed to work for other pros out there:

    // Include WordPress
    define('WP_USE_THEMES', false);
    require('./wp-load.php');
    $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
    $paged = ($_GET['paged']) ? $_GET['paged'] : 0;
    $per_page=(int)get_option('posts_per_page');
    query_posts('orderby=date&order=DESC&offset='.((int)$paged*$per_page));
    while ( have_posts() ) : the_post();
    echo '<div class="pwrap">';
    echo '<div class="ptitle"><div style="margin-left:5px;">'.the_title('','',false).'</div></div>';
    echo '<div class="pcontent"><div style="margin:5px;">'.get_the_excerpt().'</div></div>';
    echo '<div class="pfooter"><div style="margin-left:5px;">'.get_the_date().' '.get_the_time().'</div></div>';
    echo '</div>';
    endwhile;
    echo '<div style="width:100%;">';
    if($paged!="0"){
    	if($paged=="1"){
    		echo '<a style="position:relative;top:0;left:10px;color:#fff;background:#6E543A;text-decoration:none;" href="./blog.php">Newer Posts</a>';
    	}else{
    		echo '<a style="position:relative;top:0;left:10px;color:#fff;background:#6E543A;text-decoration:none;" href="./blog.php?paged='.(string)((int)$paged-1).'">Newer Posts</a>';
    	}
    }
    if(((int)$paged+$per_page)<($numposts-1)){
    	echo '<a style="position:relative;top:0;left:730px;color:#fff;background:#6E543A;text-decoration:none;" href="./blog.php?paged='.(string)((int)$paged+1).'">Older Posts</a>';
    }
    echo '</div>';
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ammunity to all query_posts&pagination 'fixes' in 3,2,1?’ is closed to new replies.