Set sidebar position disabled and hide page title through php wordpress plugin

I’ve created a plugin for wordpress that can auto post pages on demand
my problem is formatting this pages to a specific template

I need that when the post page is auto inserted in the DB, set the Sidebar position to disabled in order to have a full width page and hide the page title… this options appear in the dashboard and I can click on them one by one, but that has to be automatic, not manually.

Read More
 $my_post = array(
          'post_title'    => wp_strip_all_tags( $tituloFichaP1 ),
          'post_content'  => $content,
          'post_status'   => 'publish',
          'post_author'   => 1,
          'post_category' => array( 8,39 ),
          'post_type' => 'page',
          'post_parent' => $parentPost,
          'page_template' => 'microsite',
          'comment_status' => 'open',
 );

 wp_insert_post( $my_post );

By the way, the page_template attribute ('page_template' => 'microsite') doesn’t work either. Te post is inserted but the template is set to default.

Thanks in advance!!!

Related posts

1 comment

  1. I just go through you code, you have done a simple mistake, in “page_template” that should be a file name (filename.php) of your template not a template name . for ex. if your template microsite’s file name is microsite.php than your code will be.

    $my_post = array(
          'post_title'    => wp_strip_all_tags( $tituloFichaP1 ),
          'post_content'  => $content,
          'post_status'   => 'publish',
          'post_author'   => 1,
          'post_category' => array( 8,39 ),
          'post_type' => 'page',
          'post_parent' => $parentPost,
          'page_template' => 'microsite.php',
          'comment_status' => 'open',
      );
     wp_insert_post( $my_post );
    

    Hope this will help you.

Comments are closed.