Tip
Make sure you’ve read the core concepts behind Remote Data Blocks before extending the plugin.
Data sources and queries can be configured in the plugin UI but, sometimes, you need to write code to implement custom functionality or connect with data sources that aren’t fully supported. Remote Data Blocks provides flexible configuration, extendable classes, hooks, and filters to help you connect to any remote data source and customize the output.
Defining a data source or query in code gives you complete control over how data is fetched, processed, and rendered. In the case of unsupported APIs, it’s a necessary step to define the schema and logic for fetching data.
The included examples provide detailed code samples and templates.
For quick development, we highly recommend leveraging AI to scaffold and iterate on new integrations.
This repository includes tools for quickly starting a local development environment.
Here’s a short overview of how data flows through the plugin when a post with a remote data block is rendered:
- WordPress core loads the post content, parses the blocks, and recognizes that a paragraph block has a block binding.
- WordPress core calls the block binding callback function:
BlockBindings::get_value(). - The callback function inspects the paragraph block. Using the block context supplied by the parent remote data block, it determines which query to execute.
- The query is executed:
$query->execute(). - Various properties of the query are requested by the query runner, including the endpoint, request headers, request method, and request body. Some of these properties are delegated to the data source (
$query->get_data_source()). - The query is dispatched, and the response data is inspected, formatted into a consistent shape, and returned to the block binding callback function.
- The callback function extracts the requested field from the response data and returns it to WordPress core for rendering.