我在 wordpress 中使用了以下代码,但是在代码中调用图像时遇到了斜线问题。
global $wpdb;
$data = array();
echo $select = "SELECT * FROM `wp_posts` WHERE `post_title` LIKE '".$_REQUEST['term']."%' AND `post_type` = 'post' GROUP BY `post_title` ";
$results = $wpdb->get_results($select);
foreach($results as $result)
{
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $result->ID ), 'single-post-thumbnail' );
$explode = explode('wp-content',$image[0]);
print_r($image[0]);
$pp = "<img src='".stripslashes($image[0])."'/>";
$data[] = array(
'label' => $pp.', '. $result->post_type ,
'value' => $result->post_title
);
} echo json_encode($data);
flush();
我从阿贾克斯打来的电话。一切正常,但是当我调用图像路径时,路径将如下所示..
[{"label":"<img src='http:\/\/localhost\/sara\/wp-content\/uploads\/2013\/10\/parachute.jpg'\/>, post","value":"Pritesh Mahajan "}]
斜线自动添加。我如何解决这个问题。