Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8982975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:43:01+00:00 2026-06-15T20:43:01+00:00

I have the following code in a PHP function that is activated when I

  • 0

I have the following code in a PHP function that is activated when I install my plugin that lets you create a post or page.

Works perfect and make the page if the $post_type is “post”, but if the $post_type is “page”, then it does not work, does not create the page.:

$my_post = array(
  'post_title'    => 'My page Reql',
  'post_type'     => 'page',
  'post_name'     => 'my-page',
  'post_content'  => 'This is my page reql.',
  'post_status'   => 'publish',
  'comment_status' => 'closed',
  'ping_status' => 'closed',
  'post_author' => 1,
  'menu_order' => 0
);

wp_insert_post( $my_post );

What is the problem? I can not find the solution.

Thank you very much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:43:02+00:00Added an answer on June 15, 2026 at 8:43 pm

    I think you have to set the guid too, like this

    $PageGuid = site_url() . "/my-page-req1";
    $my_post  = array( 'post_title'     => 'My page Reql',
                       'post_type'      => 'page',
                       'post_name'      => 'my-page',
                       'post_content'   => 'This is my page reql.',
                       'post_status'    => 'publish',
                       'comment_status' => 'closed',
                       'ping_status'    => 'closed',
                       'post_author'    => 1,
                       'menu_order'     => 0,
                       'guid'           => $PageGuid );
    
    $PageID = wp_insert_post( $my_post, FALSE ); // Get Post ID - FALSE to return 0 instead of wp_error.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have the following code of my PHP page that shows me the
I have the following code: <?php function foo($bar) { global $products; //$products = array();
I have the following code: $(document).ready(function() { $.getJSON('../includes/_quiz.php?class_id=163&course_id=183',function(data){ $.each(data,function(k,v){ questions[k] = v.question; answers[k*4] =
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have the following PHP code; <?php component_customer_init(); component_customer_go(); function component_customer_init() { $customer =
I have the following code in page1.php : <a href=page2.php onClick=javascript:callFlash();>Go to page</a> This
I have the following code: <?php function search_reset() { $query = $_GET['q']; if($query) echo
I have the following code that correctly generates the CKEditor: <script> $(function(){ $(#newWrite_body).ckeditor({ extraPlugins
I have the following code which sends an AJAX POST to a php file
I have the following code at the end of an .each() function that loops

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.