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
|
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 |
|||
|
|
|
Use
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 questionRead up on conditional tags: Hence,
will do what you want. If on another pageShould 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:
|
|||
|
|