I'm still learning Wordpress and slowly getting better, but my skill set is not up to par for the changes I am asking for.
I need to customize the gallery output for two sections on my site: 1) Portfolio Pages and 2) Blog Posts
On the PORTFOLIO PAGES, I want WP to render the gallery as images tags with attributes as shown below.
<img width="575" height="500" src="ImagePath/ImageName.jpg" class="attachment-full" alt="Alt Text">
<img width="575" height="500" src="ImagePath/ImageName.jpg" class="attachment-full" alt="Alt Text">
<img width="575" height="500" src="ImagePath/ImageName.jpg" class="attachment-full" alt="Alt Text">
<img width="575" height="500" src="ImagePath/ImageName.jpg" class="attachment-full" alt="Alt Text">
Here's the code I found online that I modified. I'm not fully comprehending the $output section and not confident in modifying some of it's code. I don't need the "class='gallery-item" code but not sure what else I "don't" need. Do I need the "itemtag", "icontag", "captiontag", etc? I'm not using them but not sure if I can just delete. If I do, will they default back to the core defaults?
// ----------------------------------------------------------------
// GALLERY OUTPUT FOR PORTFOLIO PAGES
add_shortcode( 'gallery', 'modified_gallery_shortcode' );
function modified_gallery_shortcode($attr) {
if(is_page_template('page-portfolio.php')){ // EDIT this slug
$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);
}else{
$output = gallery_shortcode($attr);
}
return $output;
}
add_filter( 'use_default_gallery_style', '__return_false' );
On the BLOG POSTS, I want WP to render the gallery using an unordered list with the attributed as shown below.
<ul class="gallery">
<li><a href='ImagePath/ImageName.jpg' class="fancybox" rel="group" title='Title Text'><img width="150" height="150" src="ImagePath/ImageName.jpg" class="attachment-thumbnail" alt="Alt Text"></a></li>
<li><a href='ImagePath/ImageName.jpg' class="fancybox" rel="group" title='Title Text'><img width="150" height="150" src="ImagePath/ImageName.jpg" class="attachment-thumbnail" alt="Alt Text"></a></li>
<li><a href='ImagePath/ImageName.jpg' class="fancybox" rel="group" title='Title Text'><img width="150" height="150" src="ImagePath/ImageName.jpg" class="attachment-thumbnail" alt="Alt Text"></a></li>
</ul>
I tried modifying the "Gallery Output for Portfolio Pages to accommodate the formatting requirements for this post type, but not having any luck!
// ----------------------------------------------------------------
// GALLERY OUTPUT FOR BLOG POSTS
add_shortcode( 'gallery2', 'modified_gallery_shortcode2' );
function modified_gallery_shortcode2($attr) {
if(is_page_template('page-portfolio.php')){ // EDIT this slug
$attr['size']="full";
$attr['link']="file";
$attr['itemtag']="li";
$attr['icontag']="span";
$attr['captiontag']="p";
$output = gallery_shortcode($attr);
$output =strip_tags($output,'NOT SURE HOW TO FORMAT');
$output =str_replace(array(" class='gallery-item'"),array(""),$output);
}else{
$output = gallery_shortcode($attr);
}
return $output;
}
add_filter( 'use_default_gallery_style', '__return_false' );
ANY HELP IS VERY MUCH APPRECIATED! Thank you!