Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function post_exists( $post_name, $post_type='post' ) {
- global $wpdb;
- $query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
- $args = array();
- if ( !empty ( $post_name ) ) {
- $query .= " AND post_name LIKE '%s' ";
- $args[] = $post_name;
- }
- if ( !empty ( $post_type ) ) {
- $query .= " AND post_type = '%s' ";
- $args[] = $post_type;
- }
- if ( !empty ( $args ) )
- return $wpdb->get_var( $wpdb->prepare($query, $args) );
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment