php - Contact Form 7 Shortcode to Array -
$contact_form_value = get_post_meta( get_the_id(), 'contact-form-data', true ); $contact_explode = explode(" ",$contact_form_value); var_dump($contact_explode); $contact_form_value equals [contact-form-7 id="105" title="businessassistance"] using code above gives me wrong answer..
how convert array? need id , title
try code
<?php $contact_form_value = get_post_meta( get_the_id(), 'contact-form-data', true ); $regex = '/\[contact-form-7\s+id=[\'|"](\d+)[\'|"]\s+title=[\'|"](.+)[\'|"]\]/'; if (preg_match($regex, $contact_form_value, $matches)) { $id = $matches[1]; $title = $matches[2]; }
Comments
Post a Comment