我對我在哪裏取結果WP_query()函數解析JSON格式的web服務(API)的工作標籤。這將進一步在android應用程序中使用。 問題是我與查詢得到的是通過視覺作曲家和整個內容組成的POST_CONTENT是在像如何去除所有視覺作曲家簡碼/從WordPress的的POST_CONTENT獲取與自定義查詢
[VC_ROW][/VC_ROW][VC_COLUMN]some text[/VC_COLUMN] etc.
我想刪除/剝去內容所有這些簡碼和檢索只有平原此類標籤的形式來自它的文本。是否有任何視覺作曲家功能,通過它我可以做到這件事
<?php
require('../../../wp-load.php');
require_once(ABSPATH . 'wp-includes/functions.php');
require_once(ABSPATH . 'wp-includes/shortcodes.php');
header('Content-Type: application/json');
$post_name = $_REQUEST['page'];
if($post_name!=''){
if($post_name=='services') {
$args = array(
'post_parent' => $page['services']['id'],
'post_type' => 'page',
'post_status' => 'published'
);
$posts = get_children($args);
foreach($posts as $po){
$services_array[] = array('id'=>$po->ID,'title'=>$po->post_title,'image'=>get_post_meta($po->ID, 'webservice_page_image',true),'description'=>preg_replace("~(?:\[/?)[^/\]]+/?\]~s", '', $po->post_content));
}
$post = array(
'status'=>'ok',
'services'=>$services_array
);
echo json_encode($post);
}
}
?>
你可以試試'strip_shortcodes()'和由WordPress提供了這個功能。 –
@Rocky strip_shortcodes()沒有工作,已經嘗試過 –
你試過了嗎?正則表達式'的preg_replace( 「〜(?:?:\ [/?)[^/\] +/\] - 的」, '',$ the_content);' –