You can check whether the page exists or not, and create it only if it doesn’t already exist. get_page_by_title()
can help you in this case:
// Check if the page already exists
if( ! get_page_by_title('My page Reql') ) {
// The page doesn't exist, so let's create it
}
Also, you might want to investigate how are you calling the function. You might be calling it twice, that might be the reason it’s creating a copy of each post.
Related Posts:
- Why isn’t is_page working when I put it in the functions.php file?
- Get the ID of the page a menu item links to?
- Disable visual editor on one specific page
- How can I programmatically create “child” pages on theme activation?
- How to display error messages using WP_Error class?
- Slugs as breadcrumbs for Pages
- Check if has any sidebar active on current page
- Remove Page Title from Static Frontpage
- Target a certain page within wordpress backend (admin) i.e. Pages > About
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- Pages should have priority when using add_rewrite_rule
- Enqueuing Script in functions.php vs on the page
- Programmatically set page template based on page ID
- Delete pages and Create default pages for all new network sites
- how to change link of some wordpress pages
- Make menu structure match page heirarchy on page parent change
- Change the slug of a particular page every x hours
- How to include local menu based on page id?
- Batch update menu_order attribute alphabetically
- is_account_page() change to page slug
- Don’t delete a page if it holds users
- List all-childpages on parent-page AND list child-pages on childpage itself but not the current one?
- Display post shortcode content in the sidebar?
- Why is my page feed returning empty content?
- Function only on a specific page
- Functions For Calling Specific Elements
- Get page id or status by private pages?
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- Enqueue script on every page except one
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- How do I register a new settings page? [closed]
- Only echo Page Content (not page title & page content together)
- get content from page through AJAX
- How to assign php file(template) to several pages with same prefix page name/slug
- Remove the delete link from pages without a plugin
- Change is_front_page() to is_page() to display ‘hero’ on entire site?
- Define an extra field for all pages (with no plugin?)
- Custom field not updating via functions upon publishing
- Using array page name together with page id to deregister script
- How to add a class name to the ancestor of a post?
- How to add an excerpt and read more link to a page?
- My website is generating weired url parameters of paginated pages
- get php variable from functions php and echo it in theme template files [closed]
- How to influence the information displayed on widget inside wp-admin
- Remove Container Element From wp_nav_menu() Markup
- WordPress function like is_category for subcategory? is_subcategory?
- Using a private method as an action callback from within a class
- Auto close (hide) custom metabox / set default state
- How to activate “Description” metabox for menu item programmatically?
- Change labels on ‘Nickname’ and ‘Biographical Info’ in user-edit.php
- How to set child post categories to parent post categories when updating parent post?
- Adding WooCommerce to a Custom Theme – not working [closed]
- WooCommerce add_action hook results in 500 error
- Advice: Template structure – php blocks in sidebar or someting else?
- wp_get_post_terms() returns WP_Error in functions.php but in template it works
- Move jQuery and Migrate to footer?
- Ninja form Redirect depending on text field content [closed]
- Display Password Protected external RSS in wordpress template
- Custom HTML in specific category single page and its descendant categories
- Filter out other users comments. Visualize only own comments and editor role users’ comments
- How to properly remove style for non logged in and front page only
- WordPress converts media extention URL automatically to video player
- How do you Permanently Delete Sidebars
- help I changed one currency in woocommerce and everything is ruined [closed]
- Use .php file as page instead of wordpress page & template file?
- How to run a function in every page, every device
- Which function required?
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- Custom Query Not Paginating
- Solved: redirect to another page using functions.php
- Getting the teaser text without overriding global variables
- Problem enqueuing scripts on not single posts
- referencing the current user in a page i created in wordpress
- is_main_query() always returning false
- Counting posts and trigger it [closed]
- modifying every other element’s class inside while loop
- Adding Custom Body Class for Page: Shop
- Is it possible to use ‘wp_insert_post’ function within a for loop?
- save_post function keeps triggering: Warning: array_map(): Argument #2 should be an array… when restoring from trash
- More than one search results page template for two searches on site
- How do i create a search option for pdf’s only
- Redirect after login to current URL
- Restrict certain roles registrations by domain
- Replacing term/taxonomy archive pages with search queries
- Return ACF Field value function
- Function to draw random image from specified category destroys site logic – why?
- Issues with add_query_arg() not passing a variable
- Move captions under gallery images in twenty fourteen theme
- Force changing the Site Title and add link
- create submenu page – error function not found or invalid function name
- Undefined offset: 2
- Sorting date results from a query
- Using is_plugin_active within functions.php
- Button generate a random URL [closed]
- How do I add functionality to images?
- Text before price on WooCom
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Change Post status based on custom field date +1 day
- How to add height and width dimensions automatically to archive descriptions
- How to store page-{id}.php templates in custom folder