在古腾堡Gutenberg显示wordpress画廊图像src

问题描述

我正在使用Gutenberg认帖子编辑器来编辑我的wordpress帖子。

我曾经尝试过使用serval方法显示帖子的画廊,但没有一个起作用。

     <?PHP
    var_dump($_GET['id']);
    echo '<br/>';
    echo '<br/>';
    $gallery = get_post_gallery( $_GET['id'] /* The post ID from $_GET */,false );
    // Loop through all the image and output them one by one.
    foreach ( $gallery['src'] AS $src ) {
                ?>                
                <img src="<?PHP echo $src; ?>" class="my-custom-class" alt="gallery image" />
        <?PHP
    }
      ?>

调试提示

string(3) "404"


Notice
: Trying to access array offset on value of type bool in
/home/mialuzco/domains/mia-luz.com/public_html/wp-content/themes/mia luz/page-gallery.PHP
on line
23


Warning
: Invalid argument supplied for foreach() in
/home/mialuzco/domains/mia-luz.com/public_html/wp-content/themes/mia luz/page-gallery.PHP
on line
23

基于此piece of knowledge,我现在应该已经可以使用它了,但是什么都没用。

如何显示帖子库图像src?

编辑

My post

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)