Make WordPress Core

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#4882 closed task (blessed) (invalid)

Publish a new post in a specific category

Reported by: reus's profile reus Owned by: matt's profile matt
Milestone: Priority: normal
Severity: normal Version: 2.1.2
Component: General Keywords:
Focuses: Cc:

Description

Hi, please help me with this problem

I need to publish a new post in a specific category and use this code, but don't work.

<?php

// PASO DE VARIABLES
$title = $_POST['title'];
$content = $_POST['textarea1'];
$category = $_GET['cat'];
$author = $user_ID;

// create object class
class wm_mypost {
var $post_title;
var $post_content;
var $post_category;
var $post_status;
var $post_author; 
}

//// my first object :-)
$wm_myobject = new wm_mypost();

// fill object
$wm_myobject->post_title = $title;
$wm_myobject->post_content = $content;
$wm_myobject->post_category = $category;
$wm_myobject->post_status = 'publish';
$wm_myobject->post_author = $author;

// feed object to wp_insert_post
wp_insert_post($wm_myobject);

?>

Thanks.

Change History (3)

#1 @reus
18 years ago

  • Cc reus@… added

#2 @foolswisdom
18 years ago

  • Milestone 2.4 (next) deleted
  • Resolution set to invalid
  • Status changed from new to closed

Closing as invalid for now.

Hi reus, WordPress.org is the component for the web site. You haven't described what version you are using in the bug report (and if it is 2.1 that isn't a maintained version), you haven't described what does happen and what you expect. Finally, your question would probably better for the wordpress.org/support forums until you have confirmed that it is buggy behavior. Hope that helps.

#3 @westi
18 years ago

  • Component changed from WordPress.org to General

Note wp_insert_post takes an array of arguments not an object.

That is probably why this fails to work.

Note: See TracTickets for help on using tickets.