Skip to content

WordPress

WordPress is a component that lets you connect to a WordPress site and perform common tasks like getting posts, creating new posts, or updating existing ones. It uses the WordPress REST API, so you just need to provide the site’s URL, a username, and an application password that has the right permissions.

How it Works

When you add the WordPress component to your dashboard, you first set up a WordPress API credential. This credential stores the site’s API URL, your WordPress username, and an application password. Once the credential is selected, the component talks to the WordPress REST API over HTTPS. Depending on the operation you choose (Get, Create, or Update), it sends the appropriate HTTP request, passes any data you provide, and returns the result as a JSON‑like structure that can be used by other components.

Operations

This component offers several operations that you can select based on what you need to do. You can only use one operation at a time:

  • Get: Retrieve a list of entities (posts, pages, etc.) or a single entity by ID.
  • Create: Add a new entity to WordPress, such as a new post or page.
  • Update: Modify an existing entity identified by its ID.

To use the component, first select the operation you need in the “Operation” field.

Inputs

Input Fields

The following fields are available to configure this component. Each field may be visible in different operations:

  • Credential: Select the WordPress API credential you have set up in Nappai’s credentials section.

    • Visible in: Get, Create, Update
  • Operation: Choose which action you want to perform.

    • Visible in: Get, Create, Update
  • Entity: Pick the type of content you’re working with (e.g., Post, Page, Comment).

    • Visible in: Get, Create, Update
  • Entity ID: The ID of the entity you want to retrieve or update.

    • Visible in: Get
  • Limit: The maximum number of entities to return when fetching a list.

    • Visible in: Get
  • Order By: Field to order results by (prepend with “-” for descending order, e.g., “-date”).

    • Visible in: Get
  • Search: Look for a specific word or phrase in titles or content. Leave empty to skip filtering.

    • Visible in: Get
  • Data: The data you want to send when creating or updating an entity (e.g., title, content, status).

    • Visible in: Create, Update

Outputs

  • Result: The JSON response from the WordPress REST API. This can be a list of entities, a single entity, or a confirmation of a create/update operation. You can feed this output into other components for further processing or display.

Usage Example

Example 1 – Get the latest 5 posts

  1. Operation: Get
  2. Entity: Post
  3. Limit: 5
  4. Order By: -date (most recent first)
  5. Credential: Select your WordPress API credential

The component will return a list of the five newest posts, which you can then pass to a “Data Formatter” component to extract titles or to a “Display” component to show them on a dashboard.

Example 2 – Create a new post

  1. Operation: Create
  2. Entity: Post
  3. Data:
    {
    "title": "My New Blog Post",
    "content": "Hello, world! This is a test post.",
    "status": "publish"
    }
  4. Credential: Select your WordPress API credential

The component will create the post and return its details, including the new post ID, which you can use in subsequent steps.

  • HTTP Request – For custom API calls when you need more control than the WordPress component offers.
  • Data Formatter – To shape the JSON output into a table or list for display.
  • Display – To show the results on a dashboard or send them via email.
  • WordPress Custom – The base component that WordPress extends; useful if you need to tweak lower‑level settings.

Tips and Best Practices

  • Keep credentials secure: Store the WordPress API credential in Nappai’s credential manager and never hard‑code passwords in your workflows.
  • Use “Search” to narrow results: When pulling many posts, add a search term to limit the data you receive.
  • Check the “Limit” field: Setting a low limit reduces API load and speeds up your workflow.
  • Validate “Data” before creating: Ensure required fields (like title and content) are present to avoid errors.
  • Use “Order By” for predictable lists: Sorting by date or ID helps maintain consistent results across runs.

Security Considerations

  • The component transmits data over HTTPS, so your credentials and content are encrypted in transit.
  • Make sure the WordPress user you use has only the permissions needed for the tasks (e.g., “Author” for creating posts, “Editor” for updating).
  • Regularly rotate your application password and update the credential in Nappai.
  • Avoid exposing the component’s output in public dashboards unless you’re sure the data is safe to share.