Last active
November 10, 2016 19:48
-
-
Save joedajigalo/605c76b0b75778427474 to your computer and use it in GitHub Desktop.
Wordpress - Get Post Info by Slug.
This file contains hidden or 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 | |
| /* Get Post Info by Slug | |
| -------------------------------------------------- */ | |
| // Set the Post Slug | |
| $custom_post_slug = get_page_by_path( 'custom-post-slug-url', 'OBJECT', 'custom_post_type' ); | |
| // Post ID | |
| $custom_post_ID = $custom_post_slug->ID; | |
| // Custom Post Meta Value - Using ACF | |
| $custom_post_meta_value = get_field('custom_post_meta_key', $custom_post_ID); | |
| // Echo Post Meta | |
| echo get_the_title($custom_post_ID); | |
| echo $custom_post_meta_value; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment