To get the images from gallery_shortcode into a list I just followed the example. strip_tags seems to strip out all the elements you define, so I kept a
,img
and li
. After that I just wrapped the html in the ul
so it seems to match what you were looking for. $output
is just a string that is generated after running gallery_shortcode
and everything after is just removing stuff from that string.
You can refer back to that gallery_shortcode page to see if you need/want to keep certain attributes.
add_shortcode( 'gallery', 'modified_gallery_shortcode' );
function modified_gallery_shortcode($attr)
{
if(is_page_template('page-portfolio.php'))
{
$attr['size']="full";
$attr['link']="none";
$attr['itemtag']="li";
$attr['icontag']="span";
$attr['captiontag']="p";
$output = gallery_shortcode($attr);
$output =strip_tags($output,'<img>');
$output =str_replace(array(" class="gallery-item""),array(""),$output);
}
elseif ( 'post' === get_post_type() )
{
$attr['size']="full";
$attr['link']="file";
$attr['itemtag']="li";
$attr['icontag']="span";
$attr['captiontag']="p";
$output = gallery_shortcode($attr); // generate html
$output = strip_tags($output,'<a><img><li>'); // remove extra tags, but keep these
$output = str_replace(" class="gallery-item"", "", $output); // remove class attribute
$output = "<ul class=\"gallery\" >$output</ul>"; // wrap in ul
}
else
{
$output = gallery_shortcode($attr);
}
return $output; // final html
}
add_filter( 'use_default_gallery_style', '__return_false' );