Hey guys,
I'm new in this forum and I had a question.
I've been working on a new WordPress theme and instead of having a two links 'Older entries'/'Newer entries' on the bottom of each blog page(, which i would usually use), i decided to actually print all the numbers of the existing pages to let the viewer decide which page to go to.
Eg: First Page 1 2 3 4 5 .... Last Page
Here's my code:
if(is_home()) {
$count = wp_count_posts();
$p_posts = $count->publish;
if($p_posts % 4 == 0)
$pages = ($p_posts / 4);
else
$pages = ($p_posts / 4) + 1;
$i = 1;
echo '<a href="/?paged=1" style="margin-right:150px;">First Page</a>';
while($i <= $pages):
echo '<a href="/?paged=';
echo $i;
echo '">';
echo $i;
echo '</a>';
$i++;
endwhile;
echo '<a href="/?paged=';
echo $pages;
echo '" style="margin-left:142px;">Last Page</a>';
}
}
[You must know that i am new to php, so it might not be the best solution..]
Now, let's assume I was on page 2 'index.php/?paged=2', I want the link to lead to page 2 to be a different style, so people know that they are on page 2..
I was thinking of an if statement, but i can't think of a condition to put... I need to see on which page i am first (/?paged=2 or /?paged=3), but how can i check that? I've been through the wp functions reference, but didn't find anything..
Does anyone have a solution?
If my question isn't clear, i apologies for my english;)
Thanks in advance.