Title: getting data from posts in dynamic checkbox
Last modified: December 14, 2021

---

# getting data from posts in dynamic checkbox

 *  Resolved [liranrak](https://wordpress.org/support/users/liranrak/)
 * (@liranrak)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/getting-data-from-posts-in-dynamic-checkbox/)
 * Hi Vrata, I’m trying to expend a little the dynamic checkboxes data and hope 
   to get from you directions and ideas… 🧐💡
 * My goal is to GET from each post a metadata value (in my case – price), and add
   it to the item’s html as custom attribute (in the way there is the “data-permalink
   =“ to have also “data-price=”).
 * So you have any suggestions or ideas on the way to achieve this?
 * At the end I attend to display the selected post’s price in the form, I’m sure
   it will be useful in the future for others developers too.
 * Hoping to collaborate and cooperate together with you 🙏🏻
 * Best wishes,
    Liran

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

 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/getting-data-from-posts-in-dynamic-checkbox/#post-15163235)
 * > So you have any suggestions or ideas on the way to achieve this?
 * yes, there is a built in hook to achieve this.
 *     ```
       add_filter('cf7sg_dynamic_checkbox_options_attributes','filter_post_attr', 10,4);
       function filter_post_attr($attributes, $post, $tag, $cf7_key){
       //$tag is a WPCF7_Tag object, $tag->name contains the field name.
       //$post is the post object.
       //get your price field values and put it into the $attributes array,
       $price=...;
       $attributes['data-price'] = $price;
       return $attributes;
   
       }
       ```
   
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/getting-data-from-posts-in-dynamic-checkbox/#post-15165344)
 * the filter is availabe when you,
 * 1. click the php icon on your UI editor cell containing the dynamic field
    2.
   select the filter from the list
 * [⌊filter⌉⌊filter⌉[
 *  Thread Starter [liranrak](https://wordpress.org/support/users/liranrak/)
 * (@liranrak)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/getting-data-from-posts-in-dynamic-checkbox/#post-15166725)
 * Hi Vrata, first thank you for your super quick response.
 * The filter you mentioned first (cf7sg_dynamic_checkbox_options_attributes) did
   successfully added new attribute tag! 👍🏻
 * Unfortunately, I can’t seem to understand how to loop through your $post query
   in the filter and GET metadata value for each $post.
    I’ll be happy If you could
   show a simple working code example of how to add for each $post “data-id=$post-
   >post_id”
 * >  the filter is availabe when you
 * You should also know that I did tried to use the filter through the php icon 
   filter list as you after described, **but it doesn’t paste the right hook** (
   cf7sg_dynamic_checkbox_options_attributes) but the hook: cf7sg_dynamic_**list**
   _options_attributes…
 * Waiting for your response,
    Liran
 *  Thread Starter [liranrak](https://wordpress.org/support/users/liranrak/)
 * (@liranrak)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/getting-data-from-posts-in-dynamic-checkbox/#post-15167401)
 * >  Unfortunately, I can’t seem to understand how to…
 * My mistake, I used the wrong tag 🤦🏻‍♀️
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/getting-data-from-posts-in-dynamic-checkbox/#post-15169637)
 * no worries

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

The topic ‘getting data from posts in dynamic checkbox’ is closed to new replies.

 * ![](https://ps.w.org/cf7-grid-layout/assets/icon-256x256.png?rev=1834229)
 * [Smart Grid-Layout Design for Contact Form 7](https://wordpress.org/plugins/cf7-grid-layout/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cf7-grid-layout/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cf7-grid-layout/)
 * [Active Topics](https://wordpress.org/support/plugin/cf7-grid-layout/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cf7-grid-layout/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cf7-grid-layout/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/getting-data-from-posts-in-dynamic-checkbox/#post-15169637)
 * Status: resolved