post_exists [ WordPress Function ]
post_exists ( $title, $content = '', $date = '' )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Determine if a post exists based on title, content, and date
Source
<?php
function post_exists($title, $content = '', $date = '') {
global $wpdb;
$post_title = stripslashes( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
$post_content = stripslashes( sanitize_post_field( 'post_content', $content, 0, 'db' ) );
$post_date = stripslashes( sanitize_post_field( 'post_date', $date, 0, 'db' ) );
$query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
$args = array();
if ( !empty ( $date ) ) {
$query .= ' AND post_date = %s';
$args[] = $post_date;
}
if ( !empty ( $title ) ) {
$query .= ' AND post_title = %s';
$args[] = $post_title;
}
if ( !empty ( $content ) ) {
$query .= 'AND post_content = %s';
$args[] = $post_content;
}
if ( !empty ( $args ) )
return $wpdb->get_var( $wpdb->prepare($query, $args) );
return 0;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- post_exists (WordPress Function) - WPSeek.com
WordPress lookup for post_exists, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com - #16283 (post_exists() enhancement - don't include revisions ...
The current post_exists() function to me has a major downside. ... later change it to "DEF", post_exists("ABC") will still return true with the post ID of the revision.
core.trac.wordpress.org - post_exists() WordPress function reference, arguments and source ...
Determine if a post exists based on title, content, and date.
queryposts.com - PHPXRef 0.7 : WordPress : Function Reference: post_exists()
Function and Method Cross Reference. post_exists(). Defined at: /wp-admin/ includes/post.php -> line 483. No references found.
phpxref.ftwr.co.uk