Updated get_permalink to take ID argument.
git-svn-id: http://svn.automattic.com/wordpress/trunk@484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5751e4c587
commit
b66fe1442b
|
@ -1406,16 +1406,16 @@ function trackback_rdf($timezone = 0) {
|
|||
|
||||
/***** Permalink tags *****/
|
||||
function get_permalink($id=false) {
|
||||
global $post;
|
||||
if (!$id) {
|
||||
if (get_settings('permalink_structure')) {
|
||||
$unixtime = strtotime($post->post_date);
|
||||
global $post, $wpdb, $tableposts;
|
||||
$rewritecode = array(
|
||||
'%year%',
|
||||
'%monthnum%',
|
||||
'%day%',
|
||||
'%postname%'
|
||||
);
|
||||
if (!$id) {
|
||||
if ('' != get_settings('permalink_structure')) {
|
||||
$unixtime = strtotime($post->post_date);
|
||||
$rewritereplace = array(
|
||||
date('Y', $unixtime),
|
||||
date('n', $unixtime),
|
||||
|
@ -1426,6 +1426,20 @@ function get_permalink($id=false) {
|
|||
} else { // if they're not using the fancy permalink option
|
||||
return $file.$querystring_start.'p'.$querystring_equal.$post->ID;
|
||||
}
|
||||
} else { // if an ID is given
|
||||
$post = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id");
|
||||
if ('' != get_settings('permalink_structure')) {
|
||||
$unixtime = strtotime($post->post_date);
|
||||
$rewritereplace = array(
|
||||
date('Y', $unixtime),
|
||||
date('n', $unixtime),
|
||||
date('j', $unixtime),
|
||||
$post->post_name
|
||||
);
|
||||
return str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
|
||||
} else {
|
||||
return $file.$querystring_start.'p'.$querystring_equal.$post->ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue