/ Published in: PHP
URL: From WordPress plugin: http://wordpress.org/extend/plugins/better-nearby-posts-links/
Expand |
Embed | Plain Text
function my_prev_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '', $string_lenght=22, $pre_link) { if ( is_attachment() ) $post = & get_post($GLOBALS['post']->post_parent); else $post = get_adjacent_post($in_same_cat, $excluded_categories, true); if ( !$post ) return; $title = apply_filters('the_title', $post->post_title, $post); //create substring of the title to the last space and add dots } $dots = '...'; } else { $short = $post->post_title; $dots = ''; } $string = '<a href="'.get_permalink($post->ID).'" title="previous post: '.$title.'">'; $link = $pre . $string . $link . '</a>'; } function my_next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '', $string_lenght=22, $pre_link) { if ( is_attachment() ) $post = & get_post($GLOBALS['post']->post_parent); else $post = get_adjacent_post($in_same_cat, $excluded_categories, false); if ( !$post ) return; $title = apply_filters('the_title', $post->post_title, $post); //create substring of the title to the last space and add dots } $dots = '...'; } else { $short = $post->post_title; $dots = ''; } $string = '<a href="'.get_permalink($post->ID).'" title="next post: '.$title.'">'; $link = $pre . $string . $link . '</a>'; }
You need to login to post a comment.
