Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get WordPress post ID by slug
$post_data = get_page_by_path('my-post-slug');
$post_id = $post_data->ID;
echo 'The post ID is: '.$post_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.