我们的Wordpress网站突然停止显示所有“精选”图像。他们只是空白。当我们查看源代码时,它显示url(896)。我们尝试再次选择图像(在后端显示正常),但是在前端,该图像仍为空白且网址无效。知道如何解决该问题以及可能发生了什么吗? TIA!
要更新:下面的这段代码是用来提取特色图片(带有错误的网址)的内容:
<div class="hero homepage relative-block" style="background-image:url(<?php the_field('hero_background_image'); ?>);<?php $hero_aspect_ratio = get_field('hero_aspect_ratio'); if( $hero_aspect_ratio ) { echo "padding-top:".$hero_aspect_ratio."%;"; } ?>"></div>
编辑:-
以下内容也没有获取任何内容。有什么想法吗?
<div class="page-content">
<?php get_template_part('content-block-loop'); ?>
</div>
答案 0 :(得分:0)
您的字段 func observePreOrder() {
guard let uid = Auth.auth().currentUser?.uid else { return }
let preOrderRef = Database.database().reference(withPath: "users/profile/\(uid)/pedidos/100_PRE-ORDER/")
preOrderRef.observe( .value, with: {snapshot in
if let Pedido = snapshot.value as? NSDictionary { // "\(Pedido)"load all items on UILabel??
let keys = Pedido.allKeys // "\(keys)"load all keys on UILabel??
for key in keys { // "\(key)"load only last key on UILabel but all keys on print output?
if let nextDict = Pedido[key] as? [String: Any] { // "\(nextDict)"Load only last item on UILabel but all items on print output?
let Pizza = nextDict["PIZZA"] as? String ?? ""
let Ingredientes = nextDict["INGREDIENTES"] as? String ?? ""
let separator = " \n"
let array : [String?] = ["·Producto: \(Pizza)", nil, "·Ingredientes: \(Ingredientes)"]
let PedidoSTR = array.compactMap{ $0 }.joined(separator: separator)
self.testLabel.text = "\(nextDict)"
self.orderTitle = self.testLabel.text
self.view.layoutIfNeeded()
self.testLabel.numberOfLines = 0
self.testLabel.setNeedsDisplay()
self.testLabel.layoutIfNeeded()
print(self.testLabel.text as Any)
print(array.count as Int)
}
}
} else {
print("NANAIN")
}
})
}
返回附件ID,而不是图像的URL。将hero_background_image
与wp_get_attachment_url($id)
一起使用来返回ID,而不是get_field()
来输出值以获取附件/图像的URL:
the_field()
可能的原因:如果您使用某些metabox /自定义字段插件作为MetaBox,Toolset Types或ACF,则可能有人更改了该字段的设置,以返回附件的ID而不是URL。这样也可以解决问题。