Skip to content

Instantly share code, notes, and snippets.

@joedajigalo
Last active November 10, 2016 19:48
Show Gist options
  • Select an option

  • Save joedajigalo/605c76b0b75778427474 to your computer and use it in GitHub Desktop.

Select an option

Save joedajigalo/605c76b0b75778427474 to your computer and use it in GitHub Desktop.
Wordpress - Get Post Info by Slug.
<?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