脚本宝典收集整理的这篇文章主要介绍了php – 如何在某个div中插入图库的每个图像? WordPress的,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我的CPT:
—>>>标题<<<< ---
—>>>图像默认 – 缩略图<<< ---
—>>>强效<<<<
—>>>图像<<< —
—>>>图像<<< —
…
之后,我考虑使用自定义元数据并添加每个图像URL.但是,通过URL添加URL并不是直观的,对于用户来说,无论是新手还是高级,都可以为用户提供更多功能.此外,金额会有所不同,图片可以是1,可能是5可能是10等等.
我看到有一个plugin for WordPress,但插件不是全宽,当我将插件的CSS设置为全宽时,Mansory在视口大小调整中获得了几个错误.
注意到插件和代码的功能,我在每篇文章中看到,插件使用自己的wordpress编辑器库.它采用生成的短代码(在the_content();内部)并在Mansory类中显示图像.
我正在尝试这样做,但没有成功.
无论如何,我想做什么?
– >抓住wordpress图库的短代码并在我的砌体的div中显示每个图像< - 逻辑示例:
画廊的简码:
实际例子:
在这里,我用砌体的div执行循环.
<?PHP $args = array( 'post_tyPE' => 'gallery','showposts' => 1 ); $wp_query = new WP_Query($args); if(have_posts()): while ($wp_query -> have_posts()) : $wp_query -> the_post(); ?> <div class="ITem"> <figure style="margin: 0px !important" itemPRop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <a href="<?PHP IMAGE 1 OF GALLERY Wp; ?>" itemprop="contentUrl" data-size="1800x1200" data-index="0"> <img src="<?PHP IMAGE 1 OF GALLERY WP; ?>" class="image" itemprop="thumbnail" alt=""> </a> </figure> </div>
随着循环将出现在库中的所有图像.
<div class="item"> <figure style="margin: 0px !important" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <a href="<?PHP IMAGE 2 OF GALLERY WP; ?>" itemprop="contentUrl" data-size="1800x1200" data-index="0"> <img src="<?PHP IMAGE 2 OF GALLERY WP; ?>" class="image" itemprop="thumbnail" alt=""> </a> </figure> </div> <div class="item"> <figure style="margin: 0px !important" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <a href="<?PHP IMAGE 3 OF GALLERY WP; ?>" itemprop="contentUrl" data-size="1800x1200" data-index="0"> <img src="<?PHP IMAGE 3 OF GALLERY WP; ?>" class="image" itemprop="thumbnail" alt=""> </a> </figure> </div> and so on.....
我怎么能这样做?
<?PHP global $post; $gallery = get_post_gallery_images( $post ); foreach( $gallery as $image_url ) { ?> <div class="item"> <figure style="margin: 0px !important" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <a href="<?PHP echo $image_url ?>" itemprop="contentUrl" data-size="1800x1200" data-index="0"> <img src="<?PHP echo $image_url ?>" class="image" itemprop="thumbnail" alt=""> </a> </figure> </div> <?PHP } ?>
以上是脚本宝典为你收集整理的php – 如何在某个div中插入图库的每个图像? WordPress的全部内容,希望文章能够帮你解决php – 如何在某个div中插入图库的每个图像? WordPress的所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。