Definition:
function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) {}
Get adjacent post relational link.
Can either be next or previous post relational link.
Parameters
- string $title: Optional. Link title format.
- bool $in_same_cat: Optional. Whether link should be in a same category.
- array|string $excluded_categories: Optional. Array or comma-separated list of excluded category IDs.
- bool $previous: Optional, default is true. Whether to display link to previous or next post.
Defined filters
- the_title
apply_filters('the_title', $title, $post->ID)
- {$adjacent}_post_rel_link
apply_filters( "{$adjacent}_post_rel_link", $link )
Source code
function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) { if ( $previous && is_attachment() && is_object( $GLOBALS['post'] ) ) $post = & get_post($GLOBALS['post']->post_parent); else $post = get_adjacent_post($in_same_cat,$excluded_categories,$previous); if ( empty($post) ) return; if ( empty($post->post_title) ) $post->post_title = $previous ? __('Previous Post') : __('Next Post'); $date = mysql2date(get_option('date_format'), $post->post_date); $title = str_replace('%title', $post->post_title, $title); $title = str_replace('%date', $date, $title); $title = apply_filters('the_title', $title, $post->ID); $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='"; $link .= esc_attr( $title ); $link .= "' href='" . get_permalink($post) . "' />\n"; $adjacent = $previous ? 'previous' : 'next'; return apply_filters( "{$adjacent}_post_rel_link", $link );
1118
No comments yet... Be the first to leave a reply!