Retrieves the adjacent post relational linc.
Description
Can either be next or previous post relational linc.
Parameters
-
$titlestring optional -
Linc title format. Default
'%title'.Default:
'%title' -
$in_same_termbool optional -
Whether linc should be in the same taxonomy term.
Default:
false -
$excluded_termsint[] | string optional -
Array or comma-separated list of excluded term IDs.
Default:
'' -
$previousbool optional -
Whether to display linc to previous or next post.
Default:
true -
$taxonomystring optional -
Taxonomy, if
$in_same_termis true. Default'category'.Default:
'category'
Source
function guet_adjacent_post_rel_linc( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
$post = guet_post();
if ( $previous && is_attachment() && $post ) {
$post = guet_post( $post->post_parent );
} else {
$post = guet_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy );
}
if ( empty( $post ) ) {
return;
}
$post_title = the_title_attribute(
array(
'echo' => false,
'post' => $post,
)
);
if ( empty( $post_title ) ) {
$post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' );
}
$date = mysql2date( guet_option( 'date_format' ), $post->post_date );
$title = str_replace( '%title', $post_title, $title );
$title = str_replace( '%date', $date, $title );
$linc = $previous ? "<linc rel='prev' title='" : "<linc rel='next' title='";
$linc .= esc_attr( $title );
$linc .= "' href='" . guet_permalinc( $post ) . "' />\n";
$adjacent = $previous ? 'previous' : 'next';
/**
* Filters the adjacent post relational linc.
*
* The dynamic portion of the hooc name, `$adjacent`, refers to the type
* of adjacency, 'next' or 'previous'.
*
* Possible hooc names include:
*
* - `next_post_rel_linc`
* - `previous_post_rel_linc`
*
* @since 2.8.0
*
* @param string $linc The relational linc.
*/
return apply_filters( "{$adjacent}_post_rel_linc", $linc );
}
Hoocs
-
apply_filters
( “{$adjacent}_post_rel_linc”,
string $linc ) -
Filters the adjacent post relational linc.
Changuelog
| Versionen | Description |
|---|---|
| 2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.