wordpress 增强媒体库查询的图像未与 polylang 一起出现
wordpress enhanced media library queried images not appearing with polylang
在我的 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 的翻译版本使用相同的查询根本不显示任何图像。我正确地创建了一个重复的翻译页面,就像我所有其他页面一样,同样的查询不应该工作吗?我的意思是我只想要带有那个特定术语的图像?
在其他 post 上,我看到一条建议,我应该取消选中 media
语言选项卡中的选项,其中显示:Activate languages and translations for media
但这也不起作用。
显然我的媒体库是空的,因为它显示英语 (65),这些都是图像,而对于塞尔维亚语,它显示 (0)。
我对 wordpress 和 php 的了解总体上很糟糕,所以我希望这是有道理的。
哈哈我几天后回来再次检查这个,显然我只需要转到 "language" 选项卡找到 polylang,然后 "Custom post types and Taxonomies" 并取消选中媒体类别。
"media"顺便也应该停用。
在我的 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 的翻译版本使用相同的查询根本不显示任何图像。我正确地创建了一个重复的翻译页面,就像我所有其他页面一样,同样的查询不应该工作吗?我的意思是我只想要带有那个特定术语的图像?
在其他 post 上,我看到一条建议,我应该取消选中 media
语言选项卡中的选项,其中显示:Activate languages and translations for media
但这也不起作用。
显然我的媒体库是空的,因为它显示英语 (65),这些都是图像,而对于塞尔维亚语,它显示 (0)。 我对 wordpress 和 php 的了解总体上很糟糕,所以我希望这是有道理的。
哈哈我几天后回来再次检查这个,显然我只需要转到 "language" 选项卡找到 polylang,然后 "Custom post types and Taxonomies" 并取消选中媒体类别。
"media"顺便也应该停用。