Please or Register to create posts and topics.

Displaying Blog Posts on Forum

Hello, i know there is an option to do that but i need more specific option. Let’s say i posted a new blog post and it’s in category A. I want to show only this post in Forum Subject A. Is it possible to do?

Thanks..

Hello tala,

if you have coding-experience this should be possible with custom-code and theĀ transition_post_status hook. By default this is not possible because there are no options for this available yet.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Well i can do the code thing but where should i put this? I mean which template. That is not what i know. Anyway this could be a good option for the plugin.

You have to put the custom code into your themes functions.php. For example it could look like this:

public function createBlogTopic($new_status, $old_status, $post) {
    if ($post->post_type == 'post' && $new_status == 'publish' && $old_status != 'publish') {
        // Add logic to figure out post category.
        // Set a forum ID based on category.
        $forumID = 123;

        $post_title = apply_filters('asgarosforum_filter_automatic_topic_title', $post->post_title, $post);
        $post_content = apply_filters('asgarosforum_filter_automatic_topic_content', $post->post_content, $post);

        if (AsgarosForumContent::forumExists($forumID)) {
            AsgarosForumContent::insertTopic($forumID, $post_title, $post_content);
        }
    }
}

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Thanks for the answer that was a great solution. Can i add category name like;

$post_category->category_name == 'Guides'