我正在使用WordPress的默认图库并向其中添加类别。现在,我创建了一个带有循环的快捷码,以将库转到页面:
if(! function_exists(\'test_shortcode\')){
function lv_gallery_style_one_shortcode($atts, $content = null){
extract(shortcode_atts( array(
\'title\'=>\'\',
), $atts) );
$port=array(\'post_type\' => \'gallery\', \'category_name\' => \'beach\', \'showposts\' => -1 );
$loop=new WP_Query($port);
while ( $loop->have_posts() ) : $loop->the_post();
// HERE IS THE LOOP
return $html;
}
add_shortcode(\'gallery_test\', \'test_shortcode\' );
我知道循环运行得很好,因为当我删除\'category_name\' => \'beach\'
它显示所有类别。---------------EDIT:-----------------
我正在使用的库具有以下图标和选项:
我以为这是标准的WP画廊,我错了吗?创建新库时,右侧有一个类别部分:
如果我不能使用它们,这是用来做什么的?我不明白。---------------End EDIT:-------------
这只是一个示例代码。在完整版本中,类别名称将作为一个参数输入到快捷码中,这就是为什么我想这样做。
有什么办法可以让它发挥作用吗?
欢迎提出任何建议:)。
谢谢