Skip to content

Instantly share code, notes, and snippets.

@xafarali
Created June 9, 2013 20:11
Show Gist options
  • Save xafarali/5745007 to your computer and use it in GitHub Desktop.
Save xafarali/5745007 to your computer and use it in GitHub Desktop.
Post the page content in template via page id or slug
$pageID = 'page name or slug';
get_ID_by_slug($pageID );
// page id by slug
function get_ID_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
};
// Post Page Content
function post_page_content($page_slug) {
get_ID_by_slug($page_slug );
$id = get_ID_by_slug($page_slug );
$post = get_page($id);
$content = apply_filters('the_content', $post->post_content);
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment