Appearance
Related Items
The Related Items node fetches rows from a target table where a foreign key field matches a value from the input. Use it to resolve one-to-many relationships, such as fetching all comments for a post or all order items for an order.
Configuration
| Property | Type | Default | Description |
|---|---|---|---|
tableId | number | -- | Required. The ID of the target WP-Nexus table to query. |
foreignKeyField | string | -- | Required. The column in the target table that references the input's ID (e.g., post_id, order_id). |
localField | string | id | The field in the input data to match against the foreign key. |
Input
Accepts a single row object or falls back to the parent context if no input is connected. The localField value is extracted from the input to build the query.
Output
Returns an array of matching rows from the target table, ordered by id ASC, up to 1,000 rows.
json
[
{ "id": 10, "order_id": 5, "product_name": "Widget A", "quantity": 2, "price": 29.99 },
{ "id": 11, "order_id": 5, "product_name": "Widget B", "quantity": 1, "price": 49.99 }
]How It Works
- The node extracts the
localFieldvalue from the input (or from the parent context as a fallback). - It resolves the target table's physical SQL table name.
- It executes a prepared SQL query:
SELECT * FROM target_table WHERE foreign_key_field = %s ORDER BY id ASC LIMIT 1000. - Returns the matching rows.
Example Use Cases
Fetch order items for an order
Given an order row with id: 5, fetch all items from the order_items table:
tableId: 7 (order_items table)
foreignKeyField: "order_id"
localField: "id"Pipeline flow:
Table Query (orders) --> Related Items (order_items) --> ResultFetch comments for a blog post
Inside a repeater that iterates over posts:
tableId: 4 (comments table)
foreignKeyField: "post_id"
localField: "id"Nested relationships in a repeater
A parent repeater shows categories. Each category card has an inner pipeline:
- Parent Data -- gets the current category (e.g.,
{ id: 3, name: "Electronics" }). - Related Items -- fetches products where
category_id = 3. - Result -- outputs the products to an inner repeater.
TIP
The Related Items node only works with WP-Nexus custom tables. For relationships involving WordPress posts or terms, use a Post Query or Term Query node with whereField set to the relationship field.
WARNING
The query uses a simple WHERE clause on the foreign key field. Make sure the target table has an index on the foreignKeyField column for good performance on large datasets.