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.

I'm trying to create a master archive, and I thought maybe someone could help me out.

The way I have it set up now is pretty simple. I have author archives, which simply list every post by a certain author, as seen here:

http://www.viiinothing.com/author/ryan/

What I'd like to do is create a master archive that looks identical to this, except it displays every post by every author.

I've tried a variety of ways to make this work, including query_posts and get_archives, but all I've been able to accomplish is show a list of the last ten posts . . . but then the page numbers and "Older" and "Newer" and page numbers won't show up at the bottom (see link). I hope that makes sense. I realize why it's not doing that, but I still can't figure out how to get it to work like the author archives.

Thank you!

share|improve this question
    
Are you using next_posts_link() or some other method? –  m0r7if3r Apr 22 '12 at 21:46
add comment

1 Answer

to accomplish that, this what I did for my blog: (1) create a page template, say "masterarcive" (2) add the code in that page. (3) this code also include pagination

Here is my entire page template with the complete code I use in it:

<?php
/**
 * @package WordPress
 * @subpackage Default_Theme
 */
/*
Template Name: masterarchive
*/


get_header(); ?>

<div id="container">
            <div id="content" role="main">

<?php
$args=array(
  //'category__in' => array(1),
  'post_type' => 'post',
  'post_status' => 'publish',
  'showposts' => -1,
  'caller_get_posts'=> 1
);
$poststocount=get_posts($args);
echo '<h2>Alphabetic Index of All '. count($poststocount). ' Posts:</h2>';

$args = array('type' => 'alpha', 'echo' => 0, 'after' => '~');
$archivestring = wp_get_archives($args);
$archives = preg_split('/[~]/',$archivestring);
if ($archives) :
   $limit = 60;
   if (isset($_GET['page'])) {
      $page = $_GET['page'];
   } else {
      $page = 1;
   }
   $start = ($page - 1) * $limit;
   $range = 5;
   echo '<h2></h2>';
   echo '<ul>';
   for ($i=$start;$i<($start + $limit);++$i) {
      if ($i < sizeof($archives)) {
         echo $archives[$i];
      }
   }
   echo '<br /><br />'; // remove <br /><br />
   echo _YOUR_paginate(sizeof($archives),$limit,$range);
   echo '</ul>';    // remove </li></ul>
else:
   echo '<h2></h2>';
   echo 'There are no Archives to list';
endif;?>
</div></div> <!-- added one </div> -->
<?php get_sidebar(); ?>

<?php get_footer(); ?>

<?php function _YOUR_paginate($numrows,$limit=10,$range=7) {

    $pagelinks = "";  
   if(isset($_GET['page'])){
      $page = $_GET['page'];
   } else {
      $page = 1;
   }
   // If query_string exists, use &page=, else use ?page= .
   $currpage = $_SERVER['REQUEST_URI'];
   $qstring = preg_replace('/page=\d+/','',$_SERVER['QUERY_STRING']);  // Get rid of previous page=
   if ($qstring) {
      $paramsep = '&amp;';
   } else {
      $paramsep = '?';
   }
    if ($numrows > $limit) {
        //$currpage = str_replace("&page=".$page,"",$currpage); // Use this for non-pretty permalink
        $currpage = str_replace("?page=".$page,"",$currpage); // Use this for pretty permalink
        if($page == 1){
            $pagelinks .= "<span class=\"pageprevdead\">&laquo; PREV </span>";
        }else{
            $pageprev = $page - 1;
            $pagelinks .= "<a class=\"pageprevlink\" href=\"" . $currpage .
                    "{$paramsep}page=" . $pageprev . "\">&laquo; PREV </a>";
        }
        $numofpages = ceil($numrows / $limit);
        if ($range == "" or $range == 0) $range = 7;
        $lrange = max(1,$page-(($range-1)/2));
        $rrange = min($numofpages,$page+(($range-1)/2));
        if (($rrange - $lrange) < ($range - 1)) {
            if ($lrange == 1) {
                $rrange = min($lrange + ($range-1), $numofpages);
            } else {
                $lrange = max($rrange - ($range-1), 0);
            }
        }
        if ($lrange > 1) {
            $pagelinks .= "<a class=\"pagenumlink\" " .
                "href=\"" . $currpage . "{$paramsep}page=" . 1 . 
                "\"> [1] </a>";
            if ($lrange > 2) $pagelinks .= "&nbsp;...&nbsp;";
        } else {
            $pagelinks .= "&nbsp;&nbsp;";
        }
        for($i = 1; $i <= $numofpages; $i++){
            if ($i == $page) {
                $pagelinks .= "<span class=\"pagenumon\"> [$i] </span>";
            } else {
                if ($lrange <= $i and $i <= $rrange) {
                    $pagelinks .= "<a class=\"pagenumlink\" " .
                        "href=\"" . $currpage . "{$paramsep}page=" . $i . 
                        "\"> [" . $i . "] </a>";
                }
            }
        }
        if ($rrange < $numofpages) {
            if ($rrange < $numofpages - 1) $pagelinks .= "&nbsp;...&nbsp;";
                $pagelinks .= "<a class=\"pagenumlink\" " .
                    "href=\"" . $currpage . "{$paramsep}page=" . $numofpages . 
                    "\"> [" . $numofpages . "] </a>";
        } else {
            $pagelinks .= "&nbsp;&nbsp;";
        }
        if(($numrows - ($limit * $page)) > 0){
            $pagenext = $page + 1;
            $pagelinks .= "<a class=\"pagenextlink\" href=\"" . $currpage .
                    "{$paramsep}page=" . $pagenext . "\"> NEXT &raquo;</a>";
        } else {
            $pagelinks .= "<span class=\"pagenextdead\"> NEXT &raquo;</span>";
        }

   }

return $pagelinks;
}
?>
share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.