Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get WordPress post ID by slug
<?php
$post_data = get_page_by_path('my-post-slug');
$post_id = $post_data->ID;
if(!empty($post_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.