| 976 | * Display adjacent post relational link. |
| 977 | * |
| 978 | * Can either be next or previous post relational link. |
| 979 | * |
| 980 | * @since 2.8.0 |
| 981 | * |
| 982 | * @param string $title Optional. Link title format. |
| 983 | * @param bool $in_same_cat Optional. Whether link should be in same category. |
| 984 | * @param string $excluded_categories Optional. Excluded categories IDs. |
| 985 | * @param bool $previous Optional, default is true. Whether display link to previous post. |
| 986 | */ |
| 987 | function adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) { |
| 988 | if ( $previous && is_attachment() ) |
| 989 | $post = & get_post($GLOBALS['post']->post_parent); |
| 990 | else |
| 991 | $post = get_adjacent_post($in_same_cat,$excluded_categories,$previous); |
| 992 | |
| 993 | if ( !$post ) |
| 994 | return; |
| 995 | |
| 996 | if ( empty($post->post_title) ) |
| 997 | $post->post_title = $previous ? __('Previous Post') : __('Next Post'); |
| 998 | |
| 999 | $date = mysql2date(get_option('date_format'), $post->post_date); |
| 1000 | |
| 1001 | $title = str_replace('%title', $post->post_title, $title); |
| 1002 | $title = str_replace('%date', $date, $title); |
| 1003 | |
| 1004 | $title = apply_filters('the_title', $title, $post); |
| 1005 | |
| 1006 | $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='"; |
| 1007 | $link .= $title; |
| 1008 | $link .= "' href='" . get_permalink($post) . "' />\n"; |
| 1009 | |
| 1010 | $adjacent = $previous ? 'previous' : 'next'; |
| 1011 | echo apply_filters( "{$adjacent}_post_rel_link", $link ); |
| 1012 | } |
| 1013 | |
| 1014 | /** |
| 1015 | * Display relational links for the posts adjacent to the current post. |
| 1016 | * |
| 1017 | * @since 2.8.0 |
| 1018 | * |
| 1019 | * @param string $title Optional. Link title format. |
| 1020 | * @param bool $in_same_cat Optional. Whether link should be in same category. |
| 1021 | * @param string $excluded_categories Optional. Excluded categories IDs. |
| 1022 | */ |
| 1023 | function adjacent_posts_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { |
| 1024 | adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true); |
| 1025 | adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false); |
| 1026 | } |
| 1027 | |
| 1028 | /** |
| 1029 | * Display relational link for the next post adjacent to the current post. |
| 1030 | * |
| 1031 | * @since 2.8.0 |
| 1032 | * |
| 1033 | * @param string $title Optional. Link title format. |
| 1034 | * @param bool $in_same_cat Optional. Whether link should be in same category. |
| 1035 | * @param string $excluded_categories Optional. Excluded categories IDs. |
| 1036 | */ |
| 1037 | function next_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { |
| 1038 | adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false); |
| 1039 | } |
| 1040 | |
| 1041 | /** |
| 1042 | * Display relational link for the previous post adjacent to the current post. |
| 1043 | * |
| 1044 | * @since 2.8.0 |
| 1045 | * |
| 1046 | * @param string $title Optional. Link title format. |
| 1047 | * @param bool $in_same_cat Optional. Whether link should be in same category. |
| 1048 | * @param string $excluded_categories Optional. Excluded categories IDs. |
| 1049 | */ |
| 1050 | function prev_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { |
| 1051 | adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true); |
| 1052 | } |
| 1053 | |
| 1054 | /** |