php - wordpress php代码使用post_content调用显示来自数组内部的db图像
问题描述
我正在尝试通过 php 编码使用 wordpress 从 mysql db 获取图像。我能够获取 url 路径但不显示图像。我想显示图像以及描述和标题,但我得到了没有格式化的组合结果。
foreach ( $database_results as $result ) {
$car_model = array(
'post_name'=>wp_strip_all_tags($result->Color),
'post_content' => wp_strip_all_tags($result->title.' '. $result->descriptions.''."<?php echo '<img src='.$result->image.'/>' ?>"),
'post_title' => wp_strip_all_tags( $result->Brand . ' ' . $result->Model . ' ' . $result->Km ),
'meta_input' => array(
'id' => $result->id,
'brand' => $result->Brand,
'model' => $result->Model,
'color' => $result->Color,
'km' => $result->Km,
),
'post_type' => 'auto',
'post_status' => 'publish',
);
wp_insert_post( $car_model );
}
这是我的sql数据库表
describe wp_garage;
场地 | 类型 | 无效的 | 钥匙 | 默认 | 额外的 |
---|---|---|---|---|---|
ID | 整数 | 是的 | 无效的 | ||
图片 | 斑点 | 是的 | 无效的 | ||
牌 | 文本 | 是的 | 无效的 | ||
模型 | 文本 | 是的 | 无效的 | ||
标题 | 文本 | 是的 | 无效的 | ||
说明 | 中文本 | 是的 | 无效的 | ||
颜色 | 文本 | 是的 | 无效的 | ||
公里 | 整数 | 是的 | 无效的 |
insert into wp_garage value("5644","https://static.toiimg.com/thumb/msid-79720359,width-1070,height-580,imgsize-78661,resizemode-75,overlay-toi_sw,pt-32,y_pad-40/photo.jpg","p","p","my name","wordpress","green","12");
解决方案
推荐阅读
- sql - Oracle 程序编译 | 警告:执行完成但有警告
- grails - 为多个环境设置 SERVER_URL
- tensorflow - 无法导入 tensorflow - 奇怪的错误警报
- c++ - 无法从 GraphicScene 中选择自定义图形项
- visual-studio-2017 - Alt + Up 在向上移动行时滚动屏幕
- javascript - 在 css 中使用 `rotate()` 使聊天消息在聊天应用程序中向上增长?
- python - 100% 的 gif 不能使用 moviepy 转换为 mp4
- javascript - Jest 'projects' 配置不读取子文件夹中的 .babelrc 和 webpack.config.json
- r - 在 r 中使用 igraph 向图形添加属性
- c++ - 创建哈希表,其中每个值都是许多值的向量