- 1. init_plugin_suite_embed_posts_rest_response
- 2. init_plugin_suite_embed_posts_excerpt
- 3. init_plugin_suite_embed_posts_images
- 4. init_plugin_suite_embed_posts_favicon_url
- 5. init_plugin_suite_embed_posts_extracted_images
- 6. init_plugin_suite_embed_products_rest_response
- 7. init_embed_insert_locations
- Conclusion
Below is a breakdown of the available filters, what they do, and how you might use them in your theme or plugin.
1. init_plugin_suite_embed_posts_rest_response
This is the final filter before returning the JSON response. Use it to add, remove, or modify fields in the embed output.
// Add a custom field from post meta to the embed JSON
add_filter( 'init_plugin_suite_embed_posts_rest_response', function( $response, $post ) {
$response['custom_field'] = get_post_meta( $post->ID, '_custom_key', true );
return $response;
}, 10, 2 );
2. init_plugin_suite_embed_posts_excerpt
Customize the excerpt shown in the embed card. You can format it, translate it, or fully override it.
// Convert excerpt to uppercase
add_filter( 'init_plugin_suite_embed_posts_excerpt', function( $excerpt, $post ) {
return strtoupper( $excerpt );
}, 10, 2 );
3. init_plugin_suite_embed_posts_images
Override the list of images used in the embed. By default, the plugin extracts up to 5 images from the content, but you can provide your own list.
// Use a static image instead of extracted ones
add_filter( 'init_plugin_suite_embed_posts_images', function( $images, $post ) {
return [ 'https://example.com/static-image.jpg' ];
}, 10, 2 );
4. init_plugin_suite_embed_posts_favicon_url
Customize the favicon shown in the top corner of the embed card.
// Replace default favicon with a custom URL
add_filter( 'init_plugin_suite_embed_posts_favicon_url', function( $favicon, $post ) {
return 'https://example.com/my-favicon.ico';
}, 10, 2 );
5. init_plugin_suite_embed_posts_extracted_images
Control how the plugin extracts images from HTML content. This lets you replace the default logic with a custom parser using regex or DOMDocument.
// Keep only .jpg images and limit to 3
add_filter( 'init_plugin_suite_embed_posts_extracted_images', function( $image_urls, $html, $limit ) {
return array_slice(
array_filter( $image_urls, fn( $url ) => str_ends_with( $url, '.jpg' ) ),
0,
$limit
);
}, 10, 3 );
6. init_plugin_suite_embed_products_rest_response
Same as posts_rest_response but for WooCommerce products. Extend the embed data for product cards as needed.
// Add brand info to product embed JSON
add_filter( 'init_plugin_suite_embed_products_rest_response', function( $response, $product ) {
$response['brand'] = get_post_meta( $product->get_id(), '_product_brand', true );
return $response;
}, 10, 2 );
7. init_embed_insert_locations
Defines where the embed button appears automatically on the frontend. You can inject it after the title, before content, after content, or inside product meta.
after_title– Right after the <h1> titlebefore_content– Before the post contentafter_content– After the post contentafter_product_meta– (Woo only) After product meta section
// Show the embed button before and after the content
add_filter( 'init_embed_insert_locations', function( $locations ) {
return [ 'before_content', 'after_content' ];
} );
Conclusion
The Init Embed Posts plugin is not only lightweight and easy to use – it’s also highly extensible for developers.
With just a few lines of add_filter(), you can:
- Customize the embed JSON for use in mobile apps
- Control how images are displayed to match your brand
- Auto-inject the embed button exactly where you want it
If you’re building a deeply integrated content platform, this plugin gives you full control while keeping things fast and elegant.
Comments