2004-01-27 04:58:01 -05:00
< ? php
2004-04-21 00:12:55 -04:00
function the_permalink () {
2005-01-14 18:43:20 -05:00
echo apply_filters ( 'the_permalink' , get_permalink ());
2004-04-21 00:12:55 -04:00
}
2004-05-18 04:36:53 -04:00
function permalink_link () { // For backwards compatibility
2005-01-14 18:43:20 -05:00
echo apply_filters ( 'the_permalink' , get_permalink ());
2004-05-18 04:36:53 -04:00
}
2004-01-27 04:58:01 -05:00
function permalink_anchor ( $mode = 'id' ) {
global $id , $post ;
switch ( strtolower ( $mode )) {
case 'title' :
$title = sanitize_title ( $post -> post_title ) . '-' . $id ;
echo '<a id="' . $title . '"></a>' ;
break ;
case 'id' :
default :
echo '<a id="post-' . $id . '"></a>' ;
break ;
}
}
2004-09-04 22:41:01 -04:00
function get_permalink ( $id = false ) {
global $post , $wpdb ;
2004-06-03 22:36:46 -04:00
2004-09-04 22:41:01 -04:00
$rewritecode = array (
'%year%' ,
'%monthnum%' ,
'%day%' ,
'%hour%' ,
'%minute%' ,
'%second%' ,
'%postname%' ,
'%post_id%' ,
'%category%' ,
'%author%' ,
'%pagename%'
);
2004-08-10 01:35:59 -04:00
2004-09-04 22:41:01 -04:00
if ( $id ) {
$idpost = $wpdb -> get_row ( " SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id " );
} else {
$idpost = $post ;
}
2004-08-10 01:35:59 -04:00
2004-10-05 22:18:37 -04:00
if ( $idpost -> post_status == 'static' ) {
2004-11-16 22:45:50 -05:00
return get_page_link ( $idpost -> ID );
2004-10-05 22:18:37 -04:00
}
2004-11-12 18:08:51 -05:00
2004-09-04 22:41:01 -04:00
$permalink = get_settings ( 'permalink_structure' );
2004-08-10 01:35:59 -04:00
2004-09-04 22:41:01 -04:00
if ( '' != $permalink ) {
$unixtime = strtotime ( $idpost -> post_date );
2004-06-03 22:36:46 -04:00
2004-09-04 22:41:01 -04:00
$cats = get_the_category ( $idpost -> ID );
$category = $cats [ 0 ] -> category_nicename ;
2005-01-25 00:01:54 -05:00
if ( $parent = $cats [ 0 ] -> category_parent ) $category = get_category_parents ( $parent , FALSE , '/' , TRUE ) . $category ;
2004-09-04 22:41:01 -04:00
$authordata = get_userdata ( $idpost -> post_author );
$author = $authordata -> user_nicename ;
$rewritereplace =
array (
date ( 'Y' , $unixtime ),
date ( 'm' , $unixtime ),
date ( 'd' , $unixtime ),
date ( 'H' , $unixtime ),
date ( 'i' , $unixtime ),
date ( 's' , $unixtime ),
$idpost -> post_name ,
$idpost -> ID ,
$category ,
$author ,
$idpost -> post_name ,
);
return get_settings ( 'home' ) . str_replace ( $rewritecode , $rewritereplace , $permalink );
} else { // if they're not using the fancy permalink option
2004-12-23 20:34:47 -05:00
$permalink = get_settings ( 'home' ) . '/?p=' . $idpost -> ID ;
2004-09-04 22:41:01 -04:00
return $permalink ;
}
2004-01-27 04:58:01 -05:00
}
2004-10-05 22:18:37 -04:00
function get_page_link ( $id = false ) {
2004-12-02 21:38:11 -05:00
global $post , $wp_rewrite ;
2004-10-05 22:18:37 -04:00
if ( ! $id ) {
$id = $post -> ID ;
}
$permalink = get_settings ( 'permalink_structure' );
if ( '' != $permalink ) {
$link = get_page_uri ( $id );
2004-12-02 21:38:11 -05:00
if ( $wp_rewrite -> using_index_permalinks ()) {
2004-10-22 17:44:00 -04:00
$link = 'index.php/' . $link ;
}
2004-10-05 22:18:37 -04:00
$link = get_settings ( 'home' ) . " / $link / " ;
} else {
2004-10-08 04:06:21 -04:00
$link = get_settings ( 'home' ) . " /index.php?page_id= $id " ;
2004-10-05 22:18:37 -04:00
}
return $link ;
}
2004-11-19 15:54:16 -05:00
function get_year_link ( $year ) {
2004-12-02 21:38:11 -05:00
global $querystring_start , $querystring_equal , $wp_rewrite ;
2004-11-19 15:54:16 -05:00
if ( ! $year ) $year = gmdate ( 'Y' , time () + ( get_settings ( 'gmt_offset' ) * 3600 ));
2004-12-02 21:38:11 -05:00
$yearlink = $wp_rewrite -> get_year_permastruct ();
2004-11-19 15:54:16 -05:00
if ( ! empty ( $yearlink )) {
$yearlink = str_replace ( '%year%' , $year , $yearlink );
2004-12-02 21:38:11 -05:00
return get_settings ( 'home' ) . trailingslashit ( $yearlink );
2004-11-19 15:54:16 -05:00
} else {
2004-12-23 20:34:47 -05:00
return get_settings ( 'home' ) . '/' . $querystring_start . 'm' . $querystring_equal . $year ;
2004-11-19 15:54:16 -05:00
}
}
2004-01-27 04:58:01 -05:00
function get_month_link ( $year , $month ) {
2004-12-02 21:38:11 -05:00
global $querystring_start , $querystring_equal , $wp_rewrite ;
2004-04-24 17:52:24 -04:00
if ( ! $year ) $year = gmdate ( 'Y' , time () + ( get_settings ( 'gmt_offset' ) * 3600 ));
if ( ! $month ) $month = gmdate ( 'm' , time () + ( get_settings ( 'gmt_offset' ) * 3600 ));
2004-12-02 21:38:11 -05:00
$monthlink = $wp_rewrite -> get_month_permastruct ();
2004-11-19 15:54:16 -05:00
if ( ! empty ( $monthlink )) {
2004-01-27 04:58:01 -05:00
$monthlink = str_replace ( '%year%' , $year , $monthlink );
$monthlink = str_replace ( '%monthnum%' , zeroise ( intval ( $month ), 2 ), $monthlink );
2004-12-02 21:38:11 -05:00
return get_settings ( 'home' ) . trailingslashit ( $monthlink );
2004-01-27 04:58:01 -05:00
} else {
2004-12-23 20:34:47 -05:00
return get_settings ( 'home' ) . '/' . $querystring_start . 'm' . $querystring_equal . $year . zeroise ( $month , 2 );
2004-01-27 04:58:01 -05:00
}
}
function get_day_link ( $year , $month , $day ) {
2004-12-02 21:38:11 -05:00
global $querystring_start , $querystring_equal , $wp_rewrite ;
2004-04-24 17:52:24 -04:00
if ( ! $year ) $year = gmdate ( 'Y' , time () + ( get_settings ( 'gmt_offset' ) * 3600 ));
if ( ! $month ) $month = gmdate ( 'm' , time () + ( get_settings ( 'gmt_offset' ) * 3600 ));
if ( ! $day ) $day = gmdate ( 'j' , time () + ( get_settings ( 'gmt_offset' ) * 3600 ));
2004-05-31 13:22:25 -04:00
2004-12-02 21:38:11 -05:00
$daylink = $wp_rewrite -> get_day_permastruct ();
2004-11-19 15:54:16 -05:00
if ( ! empty ( $daylink )) {
2004-01-27 04:58:01 -05:00
$daylink = str_replace ( '%year%' , $year , $daylink );
$daylink = str_replace ( '%monthnum%' , zeroise ( intval ( $month ), 2 ), $daylink );
$daylink = str_replace ( '%day%' , zeroise ( intval ( $day ), 2 ), $daylink );
2004-12-02 21:38:11 -05:00
return get_settings ( 'home' ) . trailingslashit ( $daylink );
2004-01-27 04:58:01 -05:00
} else {
2004-12-23 20:34:47 -05:00
return get_settings ( 'home' ) . '/' . $querystring_start . 'm' . $querystring_equal . $year . zeroise ( $month , 2 ) . zeroise ( $day , 2 );
2004-01-27 04:58:01 -05:00
}
2004-06-02 03:14:03 -04:00
}
function get_feed_link ( $feed = 'rss2' ) {
2004-12-02 21:38:11 -05:00
global $wp_rewrite ;
2004-06-02 03:14:03 -04:00
$do_perma = 0 ;
$feed_url = get_settings ( 'siteurl' );
$comment_feed_url = $feed_url ;
$permalink = get_settings ( 'permalink_structure' );
if ( '' != $permalink ) {
$do_perma = 1 ;
$feed_url = get_settings ( 'home' );
2004-09-18 16:04:29 -04:00
$index = 'index.php' ;
2004-06-02 03:14:03 -04:00
$prefix = '' ;
2004-12-02 21:38:11 -05:00
if ( $wp_rewrite -> using_index_permalinks ()) {
2004-06-02 03:14:03 -04:00
$feed_url .= '/' . $index ;
}
$comment_feed_url = $feed_url ;
$feed_url .= '/feed' ;
$comment_feed_url .= '/comments/feed' ;
}
switch ( $feed ) {
case 'rdf' :
$output = $feed_url . '/wp-rdf.php' ;
if ( $do_perma ) {
$output = $feed_url . '/rdf/' ;
}
break ;
case 'rss' :
$output = $feed_url . '/wp-rss.php' ;
if ( $do_perma ) {
$output = $feed_url . '/rss/' ;
}
break ;
case 'atom' :
$output = $feed_url . '/wp-atom.php' ;
if ( $do_perma ) {
$output = $feed_url . '/atom/' ;
}
break ;
case 'comments_rss2' :
$output = $feed_url . '/wp-commentsrss2.php' ;
if ( $do_perma ) {
2005-01-21 22:45:35 -05:00
$output = $comment_feed_url . '/' ;
2004-06-02 03:14:03 -04:00
}
break ;
case 'rss2' :
default :
$output = $feed_url . '/wp-rss2.php' ;
if ( $do_perma ) {
2005-01-21 22:45:35 -05:00
$output = $feed_url . '/' ;
2004-06-02 03:14:03 -04:00
}
break ;
}
return $output ;
2004-01-27 04:58:01 -05:00
}
function edit_post_link ( $link = 'Edit This' , $before = '' , $after = '' ) {
2004-02-26 11:15:48 -05:00
global $user_level , $post ;
2004-01-27 04:58:01 -05:00
get_currentuserinfo ();
if ( $user_level > 0 ) {
$authordata = get_userdata ( $post -> post_author );
if ( $user_level < $authordata -> user_level ) {
return ;
}
} else {
return ;
}
2004-02-26 11:15:48 -05:00
$location = get_settings ( 'siteurl' ) . " /wp-admin/post.php?action=edit&post= $post->ID " ;
2004-02-19 20:53:41 -05:00
echo " $before <a href= \" $location\ " > $link </ a > $after " ;
2004-01-27 04:58:01 -05:00
}
function edit_comment_link ( $link = 'Edit This' , $before = '' , $after = '' ) {
2004-02-26 11:15:48 -05:00
global $user_level , $post , $comment ;
2004-01-27 04:58:01 -05:00
get_currentuserinfo ();
if ( $user_level > 0 ) {
$authordata = get_userdata ( $post -> post_author );
if ( $user_level < $authordata -> user_level ) {
return ;
}
} else {
return ;
}
2004-02-26 11:15:48 -05:00
$location = get_settings ( 'siteurl' ) . " /wp-admin/post.php?action=editcomment&comment= $comment->comment_ID " ;
2004-05-09 01:47:02 -04:00
echo " $before <a href=' $location '> $link </a> $after " ;
2004-01-27 04:58:01 -05:00
}
2004-06-02 03:44:43 -04:00
// Navigation links
2004-08-23 21:35:57 -04:00
function get_previous_post ( $in_same_cat = false , $excluded_categories = '' ) {
global $post , $wpdb ;
if ( ! is_single ()) {
return null ;
}
$current_post_date = $post -> post_date ;
$current_category = $post -> post_category ;
$sqlcat = '' ;
if ( $in_same_cat ) {
$sqlcat = " AND post_category = ' $current_category ' " ;
}
$sql_exclude_cats = '' ;
if ( ! empty ( $excluded_categories )) {
$blah = explode ( 'and' , $excluded_categories );
foreach ( $blah as $category ) {
$category = intval ( $category );
$sql_exclude_cats .= " AND post_category != $category " ;
}
}
return @ $wpdb -> get_row ( " SELECT ID, post_title FROM $wpdb->posts WHERE post_date < ' $current_post_date ' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT 1 " );
}
function get_next_post ( $in_same_cat = false , $excluded_categories = '' ) {
global $post , $wpdb ;
if ( ! is_single ()) {
return null ;
}
$current_post_date = $post -> post_date ;
$current_category = $post -> post_category ;
$sqlcat = '' ;
if ( $in_same_cat ) {
$sqlcat = " AND post_category = ' $current_category ' " ;
}
$sql_exclude_cats = '' ;
if ( ! empty ( $excluded_categories )) {
$blah = explode ( 'and' , $excluded_categories );
foreach ( $blah as $category ) {
$category = intval ( $category );
$sql_exclude_cats .= " AND post_category != $category " ;
}
}
$now = current_time ( 'mysql' );
return @ $wpdb -> get_row ( " SELECT ID,post_title FROM $wpdb->posts WHERE post_date > ' $current_post_date ' AND post_date < ' $now ' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT 1 " );
}
function previous_post_link ( $format = '« %link' , $link = '%title' , $in_same_cat = false , $excluded_categories = '' ) {
$post = get_previous_post ( $in_same_cat , $excluded_categories );
if ( ! $post ) {
return ;
}
$title = apply_filters ( 'the_title' , $post -> post_title );
$string = '<a href="' . get_permalink ( $post -> ID ) . '">' ;
$link = str_replace ( '%title' , $title , $link );
$link = $string . $link . '</a>' ;
$format = str_replace ( '%link' , $link , $format );
echo $format ;
}
function next_post_link ( $format = '%link »' , $link = '%title' , $in_same_cat = false , $excluded_categories = '' ) {
$post = get_next_post ( $in_same_cat , $excluded_categories );
if ( ! $post ) {
return ;
}
$title = apply_filters ( 'the_title' , $post -> post_title );
$string = '<a href="' . get_permalink ( $post -> ID ) . '">' ;
$link = str_replace ( '%title' , $title , $link );
$link = $string . $link . '</a>' ;
$format = str_replace ( '%link' , $link , $format );
echo $format ;
}
2004-06-02 03:44:43 -04:00
function previous_post ( $format = '%' , $previous = 'previous post: ' , $title = 'yes' , $in_same_cat = 'no' , $limitprev = 1 , $excluded_categories = '' ) {
global $id , $post , $wpdb ;
2004-08-16 22:29:37 -04:00
global $posts , $posts_per_page , $s ;
2004-06-02 03:44:43 -04:00
global $querystring_start , $querystring_equal , $querystring_separator ;
2004-08-16 22:29:37 -04:00
if (( $posts_per_page == 1 ) || is_single ()) {
2004-06-02 03:44:43 -04:00
$current_post_date = $post -> post_date ;
$current_category = $post -> post_category ;
$sqlcat = '' ;
if ( $in_same_cat != 'no' ) {
$sqlcat = " AND post_category = ' $current_category ' " ;
}
$sql_exclude_cats = '' ;
if ( ! empty ( $excluded_categories )) {
$blah = explode ( 'and' , $excluded_categories );
foreach ( $blah as $category ) {
$category = intval ( $category );
$sql_exclude_cats .= " AND post_category != $category " ;
}
}
$limitprev -- ;
$lastpost = @ $wpdb -> get_row ( " SELECT ID, post_title FROM $wpdb->posts WHERE post_date < ' $current_post_date ' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev , 1 " );
if ( $lastpost ) {
$string = '<a href="' . get_permalink ( $lastpost -> ID ) . '">' . $previous ;
if ( $title == 'yes' ) {
2004-06-17 20:22:09 -04:00
$string .= wptexturize ( $lastpost -> post_title );
2004-06-02 03:44:43 -04:00
}
$string .= '</a>' ;
$format = str_replace ( '%' , $string , $format );
echo $format ;
}
}
}
function next_post ( $format = '%' , $next = 'next post: ' , $title = 'yes' , $in_same_cat = 'no' , $limitnext = 1 , $excluded_categories = '' ) {
2004-08-16 22:29:37 -04:00
global $posts_per_page , $post , $wpdb ;
if ( 1 == $posts_per_page || is_single ()) {
2004-06-02 03:44:43 -04:00
$current_post_date = $post -> post_date ;
$current_category = $post -> post_category ;
$sqlcat = '' ;
if ( $in_same_cat != 'no' ) {
$sqlcat = " AND post_category=' $current_category ' " ;
}
$sql_exclude_cats = '' ;
if ( ! empty ( $excluded_categories )) {
$blah = explode ( 'and' , $excluded_categories );
foreach ( $blah as $category ) {
$category = intval ( $category );
$sql_exclude_cats .= " AND post_category != $category " ;
}
}
$now = current_time ( 'mysql' );
$limitnext -- ;
$nextpost = @ $wpdb -> get_row ( " SELECT ID,post_title FROM $wpdb->posts WHERE post_date > ' $current_post_date ' AND post_date < ' $now ' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT $limitnext ,1 " );
if ( $nextpost ) {
$string = '<a href="' . get_permalink ( $nextpost -> ID ) . '">' . $next ;
if ( $title == 'yes' ) {
2004-06-17 20:22:09 -04:00
$string .= wptexturize ( $nextpost -> post_title );
2004-06-02 03:44:43 -04:00
}
$string .= '</a>' ;
$format = str_replace ( '%' , $string , $format );
echo $format ;
}
}
}
function get_pagenum_link ( $pagenum = 1 ){
2004-12-02 21:38:11 -05:00
global $wp_rewrite ;
2004-06-02 03:44:43 -04:00
$qstr = $_SERVER [ 'REQUEST_URI' ];
$page_querystring = " paged " ;
$page_modstring = " page/ " ;
$page_modregex = " page/? " ;
2004-06-08 13:48:21 -04:00
$permalink = 0 ;
2004-09-18 16:04:29 -04:00
$index = 'index.php' ;
2004-06-02 03:44:43 -04:00
2004-09-10 03:03:40 -04:00
$home_root = parse_url ( get_settings ( 'home' ));
$home_root = $home_root [ 'path' ];
$home_root = trailingslashit ( $home_root );
$qstr = preg_replace ( '|^' . $home_root . '|' , '' , $qstr );
$qstr = preg_replace ( '|^/+|' , '' , $qstr );
2004-06-02 03:44:43 -04:00
// if we already have a QUERY style page string
if ( stristr ( $qstr , $page_querystring ) ) {
$replacement = " $page_querystring = $pagenum " ;
$qstr = preg_replace ( " / " . $page_querystring . " [^ \ d]+ \ d+/ " , $replacement , $qstr );
// if we already have a mod_rewrite style page string
} elseif ( preg_match ( '|' . $page_modregex . '\d+|' , $qstr ) ){
2004-06-08 13:48:21 -04:00
$permalink = 1 ;
2004-06-02 03:44:43 -04:00
$qstr = preg_replace ( '|' . $page_modregex . '\d+|' , " $page_modstring $pagenum " , $qstr );
// if we don't have a page string at all ...
// lets see what sort of URL we have...
} else {
// we need to know the way queries are being written
global $querystring_start , $querystring_equal , $querystring_separator ;
// if there's a querystring_start (a "?" usually), it's deffinitely not mod_rewritten
if ( stristr ( $qstr , $querystring_start ) ){
// so append the query string (using &, since we already have ?)
$qstr .= $querystring_separator . $page_querystring . $querystring_equal . $pagenum ;
// otherwise, it could be rewritten, OR just the default index ...
} elseif ( '' != get_settings ( 'permalink_structure' )) {
2004-06-08 13:48:21 -04:00
$permalink = 1 ;
2004-08-07 14:12:54 -04:00
// If it's not a path info permalink structure, trim the index.
2004-12-02 21:38:11 -05:00
if ( ! $wp_rewrite -> using_index_permalinks ()) {
2004-09-18 16:04:29 -04:00
$qstr = preg_replace ( " #/* " . $index . " /*# " , '/' , $qstr );
2004-08-23 19:28:14 -04:00
} else {
// If using path info style permalinks, make sure the index is in
// the URI.
2004-09-18 16:04:29 -04:00
if ( strpos ( $qstr , $index ) === false ) {
$qstr = '/' . $index . $qstr ;
2004-08-23 19:28:14 -04:00
}
2004-08-07 14:12:54 -04:00
}
$qstr = trailingslashit ( $qstr ) . $page_modstring . $pagenum ;
2004-06-02 03:44:43 -04:00
} else {
2004-09-18 16:04:29 -04:00
$qstr = $index . $querystring_start . $page_querystring . $querystring_equal . $pagenum ;
2004-06-02 03:44:43 -04:00
}
}
$qstr = preg_replace ( '|^/+|' , '' , $qstr );
2004-06-08 13:48:21 -04:00
if ( $permalink ) $qstr = trailingslashit ( $qstr );
2004-06-07 00:41:06 -04:00
return preg_replace ( '/&([^#])(?![a-z]{1,8};)/' , '&$1' , trailingslashit ( get_settings ( 'home' ) ) . $qstr );
2004-06-02 03:44:43 -04:00
}
function next_posts ( $max_page = 0 ) { // original by cfactor at cooltux.org
2004-07-28 23:34:08 -04:00
global $paged , $pagenow ;
2004-06-02 03:44:43 -04:00
global $querystring_start , $querystring_equal , $querystring_separator ;
2004-07-28 23:34:08 -04:00
if ( ! is_single ()) {
2004-06-02 03:44:43 -04:00
if ( ! $paged ) $paged = 1 ;
$nextpage = intval ( $paged ) + 1 ;
if ( ! $max_page || $max_page >= $nextpage ) {
echo get_pagenum_link ( $nextpage );
}
}
}
function next_posts_link ( $label = 'Next Page »' , $max_page = 0 ) {
2004-07-28 23:34:08 -04:00
global $paged , $result , $request , $posts_per_page , $wpdb ;
if ( ! $max_page ) {
2004-10-13 10:18:17 -04:00
preg_match ( '#FROM (.*) GROUP BY#' , $request , $matches );
$fromwhere = $matches [ 1 ];
$numposts = $wpdb -> get_var ( " SELECT COUNT(ID) FROM $fromwhere " );
2004-07-28 23:34:08 -04:00
$max_page = ceil ( $numposts / $posts_per_page );
}
if ( ! $paged )
$paged = 1 ;
$nextpage = intval ( $paged ) + 1 ;
if (( ! is_single ()) && ( empty ( $paged ) || $nextpage <= $max_page )) {
echo '<a href="' ;
next_posts ( $max_page );
echo '">' . preg_replace ( '/&([^#])(?![a-z]{1,8};)/' , '&$1' , $label ) . '</a>' ;
2004-06-02 03:44:43 -04:00
}
}
function previous_posts () { // original by cfactor at cooltux.org
2004-07-28 23:34:08 -04:00
global $_SERVER , $paged , $pagenow ;
2004-06-02 03:44:43 -04:00
global $querystring_start , $querystring_equal , $querystring_separator ;
2004-07-28 23:34:08 -04:00
if ( ! is_single ()) {
2004-06-02 03:44:43 -04:00
$nextpage = intval ( $paged ) - 1 ;
if ( $nextpage < 1 ) $nextpage = 1 ;
echo get_pagenum_link ( $nextpage );
}
}
function previous_posts_link ( $label = '« Previous Page' ) {
2004-07-28 23:34:08 -04:00
global $paged ;
if (( ! is_single ()) && ( $paged > 1 ) ) {
2004-06-02 03:44:43 -04:00
echo '<a href="' ;
previous_posts ();
echo '">' . preg_replace ( '/&([^#])(?![a-z]{1,8};)/' , '&$1' , $label ) . '</a>' ;
}
}
function posts_nav_link ( $sep = ' — ' , $prelabel = '« Previous Page' , $nxtlabel = 'Next Page »' ) {
2004-10-12 09:12:03 -04:00
global $request , $posts_per_page , $wpdb ;
2004-10-12 09:04:35 -04:00
if ( ! is_single ()) {
if ( get_query_var ( 'what_to_show' ) == 'posts' ) {
2004-10-13 10:18:17 -04:00
preg_match ( '#FROM (.*) GROUP BY#' , $request , $matches );
$fromwhere = $matches [ 1 ];
$numposts = $wpdb -> get_var ( " SELECT COUNT(ID) FROM $fromwhere " );
2004-10-12 09:04:35 -04:00
$max_page = ceil ( $numposts / $posts_per_page );
} else {
$max_page = 999999 ;
}
2004-08-16 18:50:06 -04:00
2004-06-02 03:44:43 -04:00
if ( $max_page > 1 ) {
previous_posts_link ( $prelabel );
echo preg_replace ( '/&([^#])(?![a-z]{1,8};)/' , '&$1' , $sep );
next_posts_link ( $nxtlabel , $max_page );
}
}
}
2004-01-27 04:58:01 -05:00
?>