I am using WordPress’s default Gallery and adding categories to them. I now created a shortcode with a loop to get the Galleries to a page:
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' );
I know that the loop worked just fine because when I remove 'category_name' => 'beach'
it displays all the categories.
—————EDIT:—————–
The Gallery I am using has the following icon and option:
I thought this is the standard WP gallery, am I wrong?
When I create a new Gallery, there is a Category section on the right side:
What is this used for if I cannot use them? I don’t understand.
—————End EDIT:————-
This is just an example code. In the complete version, the category name will be a parameter to enter in the shortcode, that is why I would like to do it like this.
Any ideas on how to get this to work?
Any suggestions are appreciated :).
Thanks.