How to get custom post type post id from slug?

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;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)