【问题标题】:wordpress enhanced media library queried images not appearing with polylangwordpress 增强的媒体库查询的图像没有出现在 polylang 中
【发布时间】:2019-02-02 16:04:37
【问题描述】:

在我的 wordpress 网站中,基本上我有这两个页面“gallery”和“galerija”(已翻译),它们在下面输出一些文本和图片库。

我使用了增强的媒体库,因此我可以用一个类别标记我的图像,并仅查询来自名为“image-gallery”的特定类别的图像,page-gallery.php 中的代码如下所示。

<?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;
?>

英文页面运行良好,但带有 polylang 的翻译版本根本不显示任何具有相同查询的图像。我正确地创建了一个重复的翻译页面,就像我的所有其他页面一样,相同的查询不应该工作吗?我的意思是我只想要具有该特定术语的图像?

在其他一些帖子中,我看到一个建议,我应该取消选中语言选项卡中media 的选项,其中显示:Activate languages and translations for media,但这也不起作用。

显然我的媒体库是空的,因为它说英语 (65) 都是图像,而对于塞尔维亚语它说 (0)。 虽然我对 wordpress 和 php 的了解一般都很差,所以我希望这是有道理的。

【问题讨论】:

    标签: php wordpress internationalization wordpress-theming polylang


    【解决方案1】:

    哈哈,几天后我回来再次检查,显然我只需要转到 polylang 的“语言”选项卡,然后转到“自定义帖子类型和分类法”并取消选中媒体类别。

    顺便说一句,“媒体”也应该被停用。

    【讨论】:

      猜你喜欢
      • 2017-05-27
      • 1970-01-01
      • 2015-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多