Use get_posts()
and the parameter name
which is the slug:
$page = get_posts([ 'name' => 'your-slug' ]);
if ( $page )
{
echo $page[0]->post_content;
}
Be aware that the post type in get_posts()
defaults to 'post'
. If you want a page use …
$page = get_posts([
'name' => 'your-slug',
'post_type' => 'page'
]);
If you want all public post types (except attachments) set the post type argument to 'any'
. Then you could get more than one result because slugs are not unique across different post types.
Related Posts:
- Where to store PHP files created by plugin / themes
- Change the_title() of a page dynamically
- What is the correct way to build a widget using OOP
- How to edit the properties of a page programmatically?
- Has anyone managed to integrate the wp_editor inside a widget?
- Pages 404 in wordpress
- Two-step login process – Is it possible?
- How to create a dynamic page based on form data with a plugin?
- Use an empty page to build custom plugin output
- Is it possible for a plugin to register a page template file?
- $wp_filesystem returns NULL. What are the dependencies?
- Dropdown list of pages to get page id to store in plugin options
- Calling a function from functions.php in custom page/ blog post
- How to store accumulate multiple option values in a single array using Options_API
- How do I approach removing menu items on the fly based on settings in my plugin?
- Set a specific page as 404 – not found via my own plugin
- Admin-ajax.php appending a status code to ajax response
- Create a Page via plugin
- Show dialog box in TinyMCE plugin and use WordPress php functions in it
- How do I alter the comment form ‘allowed tags’ text in a plugin?
- Applying OO patterns and principles to plugin development
- Global variable $post returning incorrect object
- Secure Pages Best Practice
- Failed to Open Stream: Permission Denied While Writing to an XML File in a WordPress Plugin
- Plugin generated virtual pages
- Widget HTML Display Problem
- wordpress JSONAPI introspector always limits number at 10?
- Redirect to another page using contact form 7? [closed]
- WordPress Specified file failed upload test
- Add Password Generator on password protected page
- ECHO Executing 4 Times In Head
- WordPress pages are not published due to External database connection with WPDB class
- Make Database query only when option is updated
- Getting a WordPress Debug Strategy
- Create page (not the post type) dynamically
- Multiple array for post_content on plugin activation
- page-slug.php not working but only for specific slug
- Working of foreach loop with array
- How to list all images used on a specific page?
- Create fixed static pages
- Toolbar Hidden in a Virtual Page
- Adding Permalink to Slides with ‘Simple Nivo Slider’ plugin?
- wp_insert_post generated mixed permalinks
- Setting a post’s category
- Why doesn’t update_post_meta work for certain strings?
- post content and shortcode content displaying out of order
- Set page to draft on plugin deactivation
- “Rendering of admin template [path to template] failed”
- How to determine which capability to use?
- How to create archive page to add in menu
- Load specific page when a custom URL is hit
- Plugin frontend page design irrespective of the theme used
- Custom non-template page on front end fails to render
- get_queried_object_id combined with wp_redirect gets wrong id
- foreach argument to get specific file types getting too many returns
- Plugins and how to assign urls to content
- How do I control the list of Pages an author can see?
- How to add conent (text) to Add New pages form of admin in WordPress
- auto create only 1 wp page in activate custom plugin
- Use custom clean URLs for a plug in
- Create pages for authors
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- Using a Page Template Not in Theme
- Create a custom plugin with dynamic child pages listing database records
- Generating Multiple Divi Pages from Database
- Problem with Owl Carousel, infinite loop [closed]
- Is there a way to decide from init whether we are on a certain backend page?
- Custom plugin with dynamic child pages listing database records
- Can a WordPress plugin add read-only pages?
- how query string in wordpress receive the value other than post and page [duplicate]
- include wp-blog-header not working on MAMP
- Adding set of custom fields to WordPress Post in Dashboard
- Beginner advice
- How to generate video out of images via WordPress plugin
- How to associate an existing user to a site in a multisite setup programmatically
- Changing upload dir in a plugin regardless of post type
- Any problem in using native jquery ajax style instead of using admin-ajax.php?
- Communicate between plugins
- WordPress mode for emacs?
- Plugin Repo: Why do some plugins get version charts while others don’t?
- maintaing consistent layout wordpress dashboard
- Widget translation on my plugin
- Comments do not respect display_name setting, how to make plugin to overcome this
- Upload to a remote server using wp_remote_post
- Include content of file into plugin (ob_start();;include;ob_get_clean()) without
- the_editor() function
- Change the ‘published on’ text?
- Is there a Filter that I can use to filter the tags before they are inserted in to the database?
- WordPress is automatically linking plain text email addresses
- How can I get WordPress to save comments in markdown format?
- How long should it take for a plugin to fully load into the WordPress.org plugin repository?
- Which directory in my plugin repo does WordPress Plugin Directory package?
- Is Using WordPress Supplied WYSIWYG Advisable?
- Replacing Scripts in Admin Load_Scripts
- How to filter content on Save/Publish to add rel=”nofollow” to all external links?
- How do I add a filter to wp_list_categories() to make links nofollow?
- Is it possible to use add_filter from a theme to alter a plugin’s function?
- How can I gracefully escape an error condition?
- get_the_excerpt() is not returning an empty string when the_excerpt is blank?
- What filters to call to modify the output of the entire page?