Skip to:
Content
Pages
Categories
Search
Top
Bottom

wp_insert_post(), Creating a sticky topic with forum parent parent.


  • Leo Blanchette
    Participant

    @leoclipartillustrationcom

    I’m writing a theme function which automatically creates a discussion forum for a post on publish. I can create a forum and a topic, but linking the two has proven difficult. Here is what I have:

    $forum_topic = array(
    
    'post_title' => $post->post_title . ' - test. ',
    
    'post_content' => $post->post_title . ' test',
    
    'post_name' => $post->post_title . 'test',
    
    'post_status' => 'publish',
    
    'post_parent' => $created_forum_id,
    
    'post_type' => 'topic',
    
    );
    
    $posted_topic_id = wp_insert_post($forum_topic);
    

    Then, making it sticky, this is what I’ve attempted:

    `update_post_meta( $created_forum_id, ‘_bbp_sticky_topics’, array($posted_topic_id) );`

    Both the forum and topic are created, but the parent and sticky are not assigned. How can I do this?

Viewing 3 replies - 1 through 3 (of 3 total)

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    Try bbp_insert_topic(), bbp_insert_forum(), and bbp_stick_topic()


    Leo Blanchette
    Participant

    @leoclipartillustrationcom

    Great, will do! Then when I do update_post_meta it should work as expected? or are there any other details? I appreciate the answer.


    Leo Blanchette
    Participant

    @leoclipartillustrationcom

    Nevermind – I missed your “stick_topic” suggestion. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.