doumanju2533 2015-04-07 23:08
浏览 25

从自定义帖子类型获取所有图像? - Wordpress

I'm attemping to create a 'gallery' page for my site, which will display all images from the site, and allow users to filter those by custom post types.

Is it possible to pull in all images from a CPT and attribute them to that particular CPT so they can be filtered between?

I can pull every image from across the site using:

$attachments = get_posts( array(
                'post_type' => 'attachment', 
                'post_status' => 'inherit', 
                'post_mime_type' => 'image', 
                'posts_per_page' => -1, 

                'order' => 'DESC' 
            ) );

But how could i further customise this to pull images only uploaded to a particular CPT, the desired outcome is i can have a list of filters above that match my post types, so all images across the site can be viewed via the gallery page?

Thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
    • ¥15 linux驱动,linux应用,多线程