jimmyt1988 on "Pagination, Not sure what to do"
June 11, 2010 by David Olsen
I can’t manage to get that part to work.
<?php
$request = $_SERVER['REQUEST_URI'];
if (strpos($request,'/music/')) {
$cat_name = 'Music';
} elseif (strpos($request,'/poetry/')) {
$cat_name = 'Poetry';
} elseif (strpos($request,'/pictures/')) {
$cat_name = 'Pictures';
} else {
$cat_name = 'Blog';
}
$sql = "SELECT p.* FROM $wpdb->posts p
JOIN $wpdb->term_relationships tr
ON (tr.object_id = p.ID)
JOIN $wpdb->term_taxonomy tt
ON (tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.taxonomy = 'category')
JOIN $wpdb->terms t
ON (t.term_id = tt.term_id AND t.name = '$cat_name')
WHERE p.post_type = 'post'
AND p.post_status = 'publish'
ORDER BY p.post_title ASC";
$mypages = $wpdb->get_results($sql);
if ($mypages) :
$limit = 3; // The number of posts per page
$range = 5; // The number of page links to show in the middle
$mypage = (isset($_GET['mypage'])) ? $mypage = $_GET['mypage'] : 1;
$start = ($mypage - 1) * $limit;
for ($i=$start;$i<($start + $limit);++$i) {
if ($i < sizeof($mypages)) {
// Process each element of the result array here
$post = $mypages[$i];
setup_postdata($post);?>
<div class = "leftSideWrap">
<h2><?php the_title(); echo " <small>"; the_time(get_option('date_format')); ?></small></h2>
<div class = "top"></div>
<div class = "middle">
<div class = "cornerImage"></div>
<?php the_content(); ?>
<div class = "commentSeperateLine dotted main"></div><br />
<p>
<a href="<?php comments_link(); ?>">
Add / View Comments to this post</a> -
<?php comments_number('There are currently no comments', 'There is 1 comment', 'There are % Responses' );?>
</p>
</div>
<div class = "bottom"></div>
</div>
<?php
}
}
echo _mam_paginate(sizeof($mypages),$limit,$range);
else:
echo '<h2>Sorry, There are no Pages to list</h2>';
endif;?>
</div>






Comments
Facebook comments:
Feel free to leave a comment...
and oh, if you want a pic to show with your comment, go get a gravatar!