View Single Post
Old 03-30-2010, 12:20 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,287
Quote:
Originally Posted by Angry Jew Cat View Post
Is there a way I can add a "delete post" right into the theme for when I'm logged in as an admin? So I can edit or delete on the fly while browsing my site? Just a quicklink to jump me right on to the edit screen for that post.
Code:
function wp_delete_post_link($link = 'Delete This', $before = '', $after = '')
{
	global $post;
	if ( $post->post_type == 'page' ) {
		if ( !current_user_can( 'edit_page', $post->ID ) )
			return;
	} else {
		if ( !current_user_can( 'edit_post', $post->ID ) )
			return;
	}
	$link = "<a href='" . wp_nonce_url( get_bloginfo('url') . "/wp-admin/post.php?action=delete&amp;post=" . $post->ID, 'delete-post_' . $post->ID) . "'>".$link."</a>";
	echo $before . $link . $after;
}
Code:
<?php wp_delete_post_link('Delete This', '<p>', '</p>');?>
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote