views:

126

answers:

4

Hello.

I want to customize next/previous posts links pagination to this structure:

<!--PAGINATION-->
<a href="#prev_post_link#" id="pagePrev" class="button"><span>&laquo; Önceki</span></a>
<a href="#next_post_link#" id="pageNext" class="button"><span>Sonraki &raquo;</span></a>
<!--/PAGINATION-->

So i want to echo just next/previous post link to #prev_post_link# and #next_post_link# for building custom next/prev pagination.

A: 

http://codex.wordpress.org/Function%5FReference/previous%5Fpost has some examples. I use the following in one of my sites.

<?php previous_post_link('<p id="next-link">%link</p>', 'Next Post, TRUE); ?>

The link is denoted by %link. You can add your class or wrapper around it. I do not think you can style the tag directly without core hack to Wordpress.

Any kind of styling you require can be achieved using the wrapping ID. In my example, the can be styled in css using

p#next-link a {}

Hope this helps.

Sid Vel
This function is deprecated. Also that will not solve my problem.
fatihturan
A: 

You can use get_adjacent_post() for this.

Example:

$prev_post = get_adjacent_post(false, '', true);  
$prev_post_link = ($prev_post ? get_permalink( $prev_post->ID ) : "");
$next_post = get_adjacent_post(false, '', false);  
$next_post_link = ($next_post ? get_permalink( $next_post->ID ) : "");
windyjonas
Can you explain it much more?
fatihturan
But i don't working on single.php. I'm working on "custom page template.":(http://pastie.org/private/ynhgmlii1nssswgotyaa5w)
fatihturan
A: 

There's a way to do what you're looking for in your theme template - but I've also had good luck w/ this plugin - http://wordpress.org/extend/plugins/wp-pagenavi/

If your still not having any luck after that, comment back & I'll post the code.

Tim Schoffelman
Tim Schoffelman
A: 

I solved this problem with JS:

    $('div#pagination').ready(function() { 
 if ( $('div#pagination a').length == 1 && $('div#pagination a').text() == 'Sonraki »' ) { 
  $('div#pagination a').before('<a href="javascript:;" class="button"><span>« Önceki</span></a>');
  $('div#pagination a:first').css('opacity', '.5');
 }
 if ( $('div#pagination a').length == 1 && $('div#pagination a').text() == '« Önceki' ) { 
  $('div#pagination a').after('<a href="javascript:;" class="button"><span>Sonraki »</span></a>');
  $('div#pagination a:last').css('opacity', '.5');
 }
    });
fatihturan