doukanxi4246 2019-02-02 16:04
浏览 45
已采纳

wordpress增强的媒体库查询图像不与polylang一起出现

In my wordpress site, basically i have these two pages "gallery" and "galerija" (translated) that output some text and image gallery bellow.

I used enhanced media library so i could tag my images with a category and query just the images from that specific category called "image-gallery", and the code in page-gallery.php looks like this.

<?php
$args = array(
    'post_type' => 'attachment',
    'post_status' => 'any',
    'posts_per_page' => - 1,
    'tax_query' => array(
        array(
            'oderby' => 'title',
            'order' => 'ASC',
            'field' => 'slug',
            'taxonomy' => 'media_category',
            'terms' => 'image-gallery'
        )
    )
);

$query = new WP_Query($args);

while ($query->have_posts()):
    $query->the_post();
    $image = wp_get_attachment_image_src(get_the_ID() , 'full');
    echo "<img src='" . $image[0] . "'/>";
endwhile;
?>

The english page is working fine but the translated version with polylang doesn't display any images at all with the same query. I properly created a duplicate translated page like with my all other pages, shouldn't the same query work? i mean i just want images with the that specific term?

On some other post i have seen a suggestion that i should uncheck the option in language tab for media where it says: Activate languages and translations for media but that didn't work also.

Apparently my media library is empty because it says English (65) which are all images and for Serbian it says (0). My knowledge of wordpress and php in general is bad though so i hope this makes sense.

  • 写回答

1条回答 默认 最新

  • dongyoucha0645 2019-02-10 14:32
    关注

    lol i came back several days later to check this again and apparently i just needed to go to the "language" tab for polylang and then "Custom post types and Taxonomies" and uncheck media categories.

    "media" should be deactivated also by the way.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?