wordpress - How do I utilize default gallery output options in a customized gallery shortcode? -


my end goal in of create gallery page automatically uploads images attached published post on site. in search found code below (also found here), placed in fucntions.php , works great, can't use of other gallery output options (size, order, orderby, etc...) organize images in way want. looking @ code seems if need add/introduce other output options, being new this, i'm not sure how modify code below make happen. thoughts?

/** * usage: [catgallery cat="4,5"] * attribute: array of category ids */  add_shortcode('catgallery', 'wpse_70989_cat_gallery_shortcode');  function wpse_70989_cat_gallery_shortcode($atts)  {   // $return = ''; // debug: enable debugging    $arr = array();   $cat_in = explode( ',', $atts['cat'] );   $catposts = new wp_query( array(       'posts_per_page'    => -1   ,   'category__in'      => $cat_in   ) );    foreach( $catposts->posts $post)   {      // debug: enable next line print post title     // $return .= '<strong>' . $post->post_title . '</strong><br />';      $args = array(          'post_type'     => 'attachment'     ,   'numberposts'   => -1     ,   'post_status'   => null     ,   'post_parent'   => $post->id      );      $attachments = get_posts($args);      if ($attachments)      {         foreach ( $attachments $attachment )          {             // debug: enable next line debug attachement object             // $return .= 'attachment:<br /><pre>' . print_r($attachment, true) . '</pre><br />';             $arr[] = $attachment->id;         }     }    }    // debug: disable next line if debugging    $return = do_shortcode( '[gallery include="' . implode( ',', $arr ) . '"]' );   return $return; } 

the default wordpress gallery comes orderby , size options specifed here add option do_shortcode line.

if want more complex, may have develop custom plugin.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -