Você pode tentar usar o wp_insert_post();
Dá uma lida na documentação.
Se você não consegui avisa pra eu tentar te ajudar melhor, ok?
Abraço
LOLOLO…
valeu Digo Ribeiro Deu certinho…
foi exatamente oque eu precisava..
Muito obrigado.
Cara eu achei que tinha resolvido mais fico só uma coisa que ta dificil de conseguir.. sabe como faço para fazer o uplod de uma imagem para usar como a imagem destacada ?
se eu conseguir fazer isso..
vai resolver um mega problema meu..
Eu tbm nao consigo criar o post.
Tipo eu tenho o formulário e coloco o action apontando para a pagina que cria o post, mas ele nao envia o post..
esse é meu codigo completo.
<?php get_header ();
if(count($_POST) > 0){
//Já foi enviado o post
the_post();
$titulo = $_POST['titulo'];
$depoimento = $_POST['depoimento'];
$image_data = $_POST['foto'];
$image_data = $_FILES['foto'];
$defaults = array(
'post_status' => 'draft',
'post_type' => 'post',
'ping_status' => get_option('default_ping_status'),
'post_parent' => 0,
'menu_order' => 0,
'to_ping' => '',
'pinged' => '',
'post_password' => '',
'guid' => '',
'post_content_filtered' => '',
'post_excerpt' => '',
'import_id' => 0
);
// Create post object
$my_post = array(
'post_title' => $titulo,
'post_content' => $depoimento,
'post_status' => 'pending',
'post_author' => 1,
'post_category' => array(26)
);
$upload_dir = wp_upload_dir();
$image_data = file_get_contents($image_url);
$filename = basename($image_url);
if(wp_mkdir_p($upload_dir['path']))
$file = $upload_dir['path'] . '/' . $filename;
else
$file = $upload_dir['basedir'] . '/' . $filename;
file_put_contents($file, $image_data);
$wp_filetype = wp_check_filetype($filename, null );
$attach_id = wp_insert_attachment( $attachment, $file, $post_id );
require_once(ABSPATH . 'wp-admin/includes/image.php');
$attach_data = wp_generate_attachment_metadata( $attach_id, $file );
wp_update_attachment_metadata( $attach_id, $attach_data );
set_post_thumbnail( $post_id, $attach_id );
// Insert the post into the database
wp_insert_post( $my_post );
}
?>
<form method="post" action="<?php echo get_permalink() ?>" enctype="multipart/form-data">
<li>
<label>Titulo</label>
<input type="text" name="titulo" />
</li>
<li>
<label>E-mail</label>
<input type="text" name="email" />
</li>
<li>
<label>Depoimento</label>
<input type="text" name="depoimento" />
</li>
<li>
<label>Foto</label>
<input type="file" name="foto" />
</li>
<input type="submit" value="Enviar"/>
</form>
<?php get_footer (); ?>