Get field instance by post Id
We have some project and use Vue.js. Now, our task is build template from json data that we will get via ajax.
Can i get $instance[‘some_filed’] via ajax by post_id?
This is our free support forum. Replies can take several days.
Need fast email support? Get SiteOrigin Premium
Replies
2Afte some time of styding source code, i found a solution. Here is my function
function get_widget_instance( $content, $widget_class ) { $instance = null; $post_blocks = parse_blocks($content); if( ! empty( $post_blocks ) ) { foreach( $post_blocks as $block ) { $widgets = $block['attrs']['panelsData']['widgets']; if( ! empty( $widgets ) ) { foreach( $widgets as $widget ) { if( $widget_class === $widget['panels_info']['class'] ) { $instance = $widget; break; } } } } } return $instance; }Hi Vitaly,
Great to hear you were able to come up with a solution that works for your setup.
Replies on this thread are closed.
Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.