[英]How to enable images gallery in WordPress
我正在尝试启用图像功能以在帖子的画廊中显示。
我试图通过上传图片,选择需要的图片并将其放入帖子中,以“正常”的方式在wordpress中建立一个画廊。
$post_id = 83;
$queried_post = get_post($post_id);
$title = $queried_post->post_title; ?>
<div id="gallery" class="section-top">
<h1 class="section-heading"> <?php echo $title; ?></h1>
<p class="center-find"><?php echo $queried_post->post_content;?></p>
</div>
我需要能够在网站上显示图库。 当我使用已检查的随机图片库中的简码时,我可以在帖子中看到图像,但是当我在front-page.php
上进入我的网站时,我得到的只是显示的实际简码而没有图像。
如果我以“查看帖子”的形式打开该帖子,则会显示图库,因此我想我的代码中缺少某些内容以将图像显示在首页上。
如果直接在front-page.php
使用短代码,我front-page.php
获得图库,但是我的用户无法像他们想要的那样制作图库,而必须自己手动编辑模板文件,对编码一无所知。
如果您希望帖子内容通过短代码,则应对其应用过滤器。 您可能还想使用get_the_title代替post对象。
$post_id = 83;
$queried_post = get_post($post_id);
$content = apply_filters( 'the_content', $queried_post->post_content );
$title = get_the_title($post_id);
<div id="gallery" class="section-top">
<h1 class="section-heading"> <?php echo $title; ?></h1>
<p class="center-find"><?php echo $content; ?></p>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.