/**
* echo the previous_next_links according the settings in the args array.
*
*
*/
function previous_next_links() {
if (is_singular(APP_POST_TYPE)) {
$args = array (
'format' => '%link',
'linkr' => '« %title',
'linkl' => '%title »',
'in_same_cat' => FALSE,
'excluded_categories' => '',
'title_length' => 38
);
echo '<span class="current" style="float:right;"> ';
echo my_adjacent_post_link($args['format'], $args['linkr'], $args['in_same_cat'], $args['excluded_categories'], true,$args['title_length']);
echo ' ';
echo my_adjacent_post_link($args['format'], $args['linkl'], $args['in_same_cat'], $args['excluded_categories'], false,$args['title_length']);
echo '</span><p/>';
}
}
/**
* return a modified version of adjacent post link. Instead to echo it, we return this as a string.
*
* Can be either next post link or previous.
*
* @since 2.5.0
* @updated for clasipress by silver
*
* @param string $format Link anchor format.
* @param string $link Link permalink format.
* @param bool $in_same_cat Optional. Whether link should be in a same category.
* @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
* @param bool $previous Optional, default is true. Whether to display link to previous or next post.
* @param int $title_length Optional. How long should be the title, in chars
*/
function my_adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true, $title_length=0) {
if ( $previous && is_attachment() )
$post = & get_post($GLOBALS['post']->post_parent);
else
$post = get_adjacent_post($in_same_cat, $excluded_categories, $previous);
if ( !$post )
return;
$title = $post->post_title;
if ( empty($post->post_title) )
$title = $previous ? __('Previous Post') : __('Next Post');
$title = apply_filters('the_title', $title, $post->ID);
$rel = $previous ? 'prev' : 'next';
if ($title_length) {
$title=substr($title,0,$title_length);
}
$string = '<a href="'.get_permalink($post).'" rel="'.$rel.'">';
$link = str_replace('%title', ucfirst($title), $link);
$link = $string . $link . '</a>';
$format = str_replace('%link', $link, $format);
$adjacent = $previous ? 'previous' : 'next';
return apply_filters( "{$adjacent}_post_link", $format, $link );
}
<div class="pad2 dotted"></div>
<?php previous_next_links(); ?>
// my function from functions.php
previous_next_links();
// my function from functions.php
previous_next_links(;)
echo '</div>';
endif;
}
ggriffin (April 11th, 2012), villadecker (April 17th, 2012)
ggriffin (April 18th, 2012), paulogoode (September 21st, 2014)
There are currently 1 users browsing this thread. (0 members and 1 guests)