[英]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
is equals to this [contact-form-7 id="105" title="BusinessAssistance"]
using the code above gives me the wrong answer.. $contact_form_value
于此[contact-form-7 id="105" title="BusinessAssistance"]
使用上面的代码给了我错误的答案。
how to convert that to array? 如何将其转换为数组? I need the id and the title 我需要身份证和标题
Try this 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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.