php - WordPress | 如何将内容放在regulr HTML周围的POST的开头和结尾?
问题描述
我有一个 wordpress 网站,我需要以某种方式将可更新的内容放在围绕常规 HTML 的 POST 中,这是半自动半静态的。这是代码:
<img src="https://website.xyz/img.jpg" class="fullimgfirst" alt="">
<img src="https://website.xyz/img3.jpg" class="leftimg" alt="">
<img src="https://website.xyz/img4.jpg" class="rightimg" alt="">
<img src="https://website.xyz/img5.jpg" class="fullimg" alt="">
<div class="firstfull">
<div class="firstleft">
<p1>Branding + Digital</p1>
</div>
<div class="firstright">
<h1>Summit</h1>
</div>
</div>
<div class="secondfull">
<h2>Project overview</h2>
<p2>The project description.</p2>
</div>
<img src="https://website.xyz/img2.jpg" class="bigimg" alt="">
<img src="https://website.xyz/img3.jpg" class="leftimg" alt="">
<img src="https://website.xyz/img4.jpg" class="rightimg" alt="">
<img src="https://website.xyz/img10.jpg" class="fullimglast" alt="">
用户只需要更新所有图像和 P2。但正如您所见,第一行和最后一行都有图像。如何在 wordpress 中保持这部分静态:
<div class="firstfull">
<div class="firstleft">
<p1>Branding + Digital</p1>
</div>
<div class="firstright">
<h1>Summit</h1>
</div>
</div>
<div class="secondfull">
<h2>Project overview</h2>
每个帖子的图片和 P2 可上传/可更新?
非常感谢您。
解决方案
您可以使用 ACF 插件。
为此,您必须为顶部和底部图像创建两个 ACF 中继器字段。并根据您的结构在模板中调用该 ACF 字段。
而 P2 将来自管理页面 editor()
你可以像这样做你的代码:
<?php if( have_rows('top_content_images') ): ?>
<?php while( have_rows('top_content_images') ): the_row();
$top_image = get_sub_field('content_image');
?>
<?php echo wp_get_attachment_image( $top_image, 'full' ); ?>
<?php endwhile; ?>
<?php endif; ?>
<div class="firstfull">
<div class="firstleft">
<p1>Branding + Digital</p1>
</div>
<div class="firstright">
<h1>Summit</h1>
</div>
</div>
<div class="secondfull">
<h2>Project overview</h2>
<?php the_content();?>
</div>
<?php if( have_rows('bottom_content_images') ): ?>
<?php while( have_rows('bottom_content_images') ): the_row();
$bottom_image = get_sub_field('content_image');
?>
<?php echo wp_get_attachment_image( $bottom_image, 'full' ); ?>
<?php endwhile; ?>
<?php endif; ?>
推荐阅读
- python - AttributeError:“ModbusIOException”对象没有属性“寄存器”
- r - 努力创建 ROC 曲线时出现代码错误
- ajax - Select2 输出中的 groupBy
- javascript - 根据选择的输入数字迭代 v-for
- keycloak - 在经过身份验证的 keycloak 后,页面会一次又一次地重新加载
- java - 无法将“java.lang.String”类型的值转换为所需的“long”类型;嵌套异常是 java.lang.NumberFormatException: For input string: ""
- python-3.x - 如何将字符串打印到html
- oracle - 从 per_grades 中选择两行具有相同等级的一行
- python - 为什么在 cmd.Cmd 子类函数中退出 ipdb 会退出该函数?
- git - 从签出的 Git 分支中找到“父”分支的可靠方法