Since you want to check for a certain page, you could use one of the following functions, for instance:
get_post
: Takes a post ID and returns the database record for that post, which can also be a page.get_page_by_title
: Retrieves a post given its title. If more that one post uses the same title, the post with the smallest ID will be returned.
Or you could write your own little function to get the page by its slug:
function get_page_by_slug($slug) {
if ($pages = get_pages())
foreach ($pages as $page)
if ($slug === $page->post_name) return $page;
return false;
} // function get_page_by_slug
You would use it like so then:
if (! get_page_by_slug('kns-products')) {
...
}
Related Posts:
- How to structure a plugin
- is_plugin_active function doesn’t exist
- Custom pages with plugin
- Pass PHP variable to javascript
- WordPress Plugin Development In MVC Architecture, How?
- Is it a good idea to edit an already existing plugin to add more functionality?
- Creating a WordPress admin page without a menu for a plugin
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- How can I limit functionality in one version of a plugin?
- Which functions in theme or plugin load first
- WordPress Plugin as ‘Library’ From Abstract Application?
- Add CSS animation as Preloader to WordPress
- How to list the Hooks and order of execution in current loading page? [duplicate]
- Updating post meta for custom post types
- Failed to invoke other hook from the init hook
- Created Widget Not Showing up on Admin Panel
- REST-API: extend media-endpoint
- Replace existing pages with new pages, keep menu links
- Distributing and packaging plugins
- Copyright messages for a particular set of pages
- How can plugins have their own pages?
- Is there a way to alter the order in which the plugins appear in the page?
- Custom plugins/Manipulated plugins: Always a terrible idea to inherit these types of WP sites that discourage updates? [closed]
- Create a custom page template inside my wordpress plugin
- How to use get_theme_mod in gutenberg editor wordpress?
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- My plugin wants to update another plugin
- View Private Published Page with URL Code (no login required)
- JS Support Ticket – Auto create WP account
- Input with spaces in Shortcode attributes overwritten by defaults
- Edit Yoast SEO breadcrumbs output [closed]
- Disable woocommerce cookies and delete cart data automatically
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Run plugins only on certain pages
- custom payment gateway in woocommerce failed to connect to remote api server
- Best way to maintain and update 3rd-party WP plugin when developer is unresponsive?
- Customization API for plugin development
- Fromcraft Plugin On click submit button [closed]
- How to redirect users to their profile after they successfully edit their profile
- Proper way to replace the_content only for pages created by custom plugin
- Redirect to another page using contact form 7? [closed]
- Custom post types – remove default post supports through empty array?
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Plugin function inside custom plugin
- Loop in elementor custom widget not working
- Minimize and Uglify WordPress Plugin Files
- How to create a plugin that includes all the other plugins?
- Why is it important to check for isset and is_array before checking in_array in this example?
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- Calling a save function from a “submit” button
- Delete data from custom table when deleting a post
- Integrating Custom Database with WordPress
- Custom Module, Extending WP with a Plugin?
- What is the best way to make a custom page from a plugin?
- unregister a sidebar widget
- Custom Post Type, Custom Columns List
- Pass PHP variable to javascript
- How to keep plugin (media-sync) running even the tab is closed?
- Check if theme supports sidebar
- Elementor: How to design Dropdown Select Box Navigation page like Chegg
- How to access a wordpress plugin page or add posts without doing it from the WordPress dashboard?
- Adding LOAD MORE on a page
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Ultimate Members Default Post Layout problem
- WordPress Frontend Page using Plugin
- Move plugin pages from dashboard to front-end
- Create survey that redirects to sidebar menu customized to answers
- Custom wp_list_tables redirect on specfic page
- Paid Membership Pro displaying a user name in PHP
- Installation failed, trying to install ANY plugin
- Load my Inline js footer area
- Woocommerce list variations that are added already to cart in Single Product
- Echo custom admin field into a is_single()
- How to use custom footer template in a site-plugin?
- Creating Nested custom fields
- Best approach to serve static content within a regular page
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- Custom pages with plugin
- Update Plugin Without Overwriting Custom Settings
- Restrict my pages from public
- How to tell which Plugin is displaying?
- Display_rows() and column_cb() strange behaviour
- How can I pass value to function in add_menu_page?
- Multiselect value in wp_query
- show Visual form builder in the front end
- Redirect url in plugin to somewhere else?
- How wordpress plugin hooks works? [duplicate]
- How to generate a responsive output from plugin?
- WordPress Code Access to Restricted Content without Registration
- How to add image for custom taxonomy
- What can I do to customize a widget provided with this plugin? from where have I to start?
- WordPress Customise
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- Create Custom Coupon Type
- WordPress isn’t sending welcome email with the password reset
- Meta box not displaying on the plugin page
- How to make a Template page to show the information of different things Shop and Product page?
- How to access the page without registering in wordpress