Created
April 29, 2022 19:18
-
-
Save someguy9/ebccfda604a520acc5be3a7126e28a14 to your computer and use it in GitHub Desktop.
Get a post ID based on its title in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$post_details = get_page_by_title( 'My Post Title', '', 'post' ); | |
echo $post_details->ID; | |
$page_details = get_page_by_title( 'My Page Title', '', 'page' ); | |
echo $page_details->ID; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment