You can use get_page_by_path()
– don’t let the name fool you, third argument is the post type:
if ( $post = get_page_by_path( 'the_slug', OBJECT, 'post_type' ) )
$id = $post->ID;
else
$id = 0;
You can use get_page_by_path()
– don’t let the name fool you, third argument is the post type:
if ( $post = get_page_by_path( 'the_slug', OBJECT, 'post_type' ) )
$id = $post->ID;
else
$id = 0;