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]
- How to add multiple custom URL variables?
- Problem creating cron job wordpress
- Making a custom widget that includes a tinymce and works in Site Origin Page Builder
- What’s the better way to add an inline script?
- Adding JS function as third parameter in do_action
- How to assign a WP 3.0 custom nav menu to a theme’s navigation menu location via script?
- Order properties should not be accessed directly
- Backbone event attachment:compat:ready can’t hook
- Add a class to a dynamic sidebar’s wrapper
- Custom user login page by creating a plugin
- Detect front-end pages only in init hook
- Whitelisting items from custom options page
- Add_menu_page not displaying the menu in class based plugin
- configuration of .htaccess for add_rewrite_rule to make sense
- How to get post meta in functions?
- Plugin access to average users not only admin
- Rewrite not working since upgrade to 5.9
- Can display plugin without shortcode?
- I am having errors with checkout on wordpress
- Hook for validating and rejecting frontend image upload
- Hide a specific category title from displaying on site
- Plugin removes itself if mistake made during edit
- Using meta_key & meta_value in add_rewrite_rule
- Can’t create a blank template
- Custom Registration Form and Passwords
- Is there a way to tell if a shorcode’s handler is being run before or after the content formatting filter?
- How to create an embedded code for wordpress shortcode?
- Why this plugin is not working?
- How to add additional field in a table row after creating a table?
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- Is it possible to convert various image types from remote URLs to WebP and then serve them immediately?
- Elementor Top-Bar
- How to override plugin function in code snippets WordPress
- How to disable page create for custom post type, but allow a page with the post types slug to be created?