Title: Access blockProps from render callback
Last modified: December 21, 2022

---

# Access blockProps from render callback

 *  [Yoshiki Ohshima](https://wordpress.org/support/users/yoshikiohshima/)
 * (@yoshikiohshima)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/access-blockprops-from-render-callback/)
 * I am two days in to make a custom dynamic block with PHP callback. Its basics
   are working! and now trying to clean up the style and size of the created element.
 * My callback in PHP returns an iframe. This is the last line of the callback:
 * return ‘<iframe width=800 height=800 src=”[https://example.com/test.html”/&gt](https://example.com/test.html”/&gt);
 * and it does show the iframe in the view. However I think I need to add all properties
   that would be added in JS (by {…blockProps}) from the PHP callback to make the
   rendered block nicely formatted with the rest of content.
 * How do I do it? Namely, I’d like to return the iframe with proper class names
   and id and other things in the blockProps.
 * My registration function looks like this:
 *     ```wp-block-code
       function test_dynamic_init() {
           require_once(ABSPATH . 'wp-admin/includes/media.php');
           require_once(ABSPATH . 'wp-admin/includes/file.php');
           require_once(ABSPATH . 'wp-admin/includes/image.php');
   
           register_block_type( __DIR__ . '/build', array(
               'render_callback' => 'test_dynamic_render_callback'
           ) );
       }
   
       add_action( 'init', 'test_dynamic_init');
       ```
   
 * and not have wp_register_script() call. Is it somehow the reason?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [MelissaH](https://wordpress.org/support/users/leeseoftbc/)
 * (@leeseoftbc)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/access-blockprops-from-render-callback/#post-16314549)
 * This may not be the best method but my workaround is to create and save the class
   name and other block props as an attribute.
   I’m hoping that someone else has 
   a better answer!
 *  Thread Starter [Yoshiki Ohshima](https://wordpress.org/support/users/yoshikiohshima/)
 * (@yoshikiohshima)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/access-blockprops-from-render-callback/#post-16314577)
 * Thanks. Looking at other blocks CSS classes in the default theme, only class 
   I need seems to be is-layout-flex class so I added to a div element that now 
   contains the iframe I actually want to show. As I wrote I was 2 days in (and 
   now 3 days in) to WorldPress blocks programming so I can’t tell if this is fine
   for all other themes and things.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Access blockProps from render callback’ is closed to new replies.

## Tags

 * [custom block](https://wordpress.org/support/topic-tag/custom-block/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [Yoshiki Ohshima](https://wordpress.org/support/users/yoshikiohshima/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/access-blockprops-from-render-callback/#post-16314577)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
