I searched everywhere for this but couldn't find any help. I'm working on a plugin that generates posts from a database, like so:
foreach ( $items as $item ) {
$content = $core->parseTpl($item->Asin, $this->content);
$titleColumn = $this->titleColumn;
$postarr = array(
'post_content' => $content,
'post_title' => $item->$titleColumn,
'post_status' => 'draft',
);
$postId = wp_insert_post( $postarr );
//more code...
}
When I do this, the generated permalinks look something like this:
However, I want the permalinks to look like specified in the WP-backend:
Using the wp_insert_post function doesn't seem to apply the permalink formatting. What do I have to do, so that my created posts have the formatted permalinks?
/?p=123
, the pretty permalink is being generated later using rewrite rules. What does it output if you useget_permalink($id);
?get_permalink($id)
I get/?p=123