I'm trying to get page content when I only know the slug string.
Is there a function for this, or an easy way to do this or is this a case of doing it via SQL?
Thanks very much
Be aware that the post type in
If you want all public post types (except attachments) set the post type argument to
If on the page with the slug in question
will do what you want.
If on another page
Should you be interested on how to fetch post/page content based on a slug when not on said page, you can feed
The following will fetch the id from a slug:
You can get a page by its title using
You can use it like this (assuming you want to show the content):
BTW, to Get page using slug:
for more refernce see WordPress Function Reference