markwilliams21 (@markwilliams21)

Forum Replies Created

Viewing 1 replies (of 1 total)

  • markwilliams21


    Certainly! In the WordPress REST API, creating a new topic and assigning it to a parent forum involves utilizing the wp/v2 endpoints for both forums and topics. To achieve this, you can follow these steps:

    ### 1. Get the Forum ID
    Firstly, you’ll need to know the ID of the parent forum to which you want to assign the new topic. You can retrieve this ID by making a GET request to the forums endpoint, typically /wp/v2/forums.

    For example:
    GET /wp/v2/forums

    ### 2. Create a New Topic
    Make a POST request to the topics endpoint, usually /wp/v2/topics, providing the necessary parameters including title, content, and forum to link it to the specific forum.

    For example:
    POST /wp/v2/topics
    Content-Type: application/json

    “title”: “New Topic Title”,
    “content”: “Content of the new topic”,
    “forum”: <forum_id>
    Replace <forum_id> with the ID of the parent forum retrieved from step 1.

    ### Example Using cURL
    Using cURL, the process might look something like this:
    curl -X POST -H “Content-Type: application/json” -d ‘{“title”:”New Topic Title”,”content”:”Content of the new topic”,”forum”:1}’
    Replace with your actual WordPress site URL and 1 with the ID of the desired forum.

    Remember to authenticate the API request if your WordPress site requires authentication for creating new content.

    This approach allows you to create a new topic and assign it to a parent forum via the WordPress REST API. Adjust the endpoint URLs and parameters as needed based on your specific WordPress configuration.

Viewing 1 replies (of 1 total)