Hey all, just a quick question. I know NewsPaper and Newsmag themes already have the lightbox functionality for single image, so hopefully this shouldn’t be too tedious to do. I wanted for each Gallery inserted into the post that it would open in a lightbox like seen here: http://thecurvyfashionista.com/2015/12/new-years-eve-plus-size-dress/ and the image attachments would show like they do in the ligthbox of the post example linked. It uses the default WordPress gallery with some php and css tweaks.
I see on that site they use the image.php or the attachment.php file and some css to do this, my question is, in NewsPaper’s attachment.php what would I need to tweak to possibly get it to sit in a similar layout for the galleries? Or would I need to create a separate file that only targets when galleries are added to a post? Please advise.
I can add in the php file code they are using:
<?php
/**
* @package WordPress
* @subpackage TCF2015
*/
get_header();
if ( have_posts() ) : while ( have_posts() ) : the_post();
//count total images + find current image number
global $post;
$attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) );
$count = count( $attachments );
$specific = array();
$i = 1;
?>
<section id="mainContent">
<div id="photoFull">
<?php $att_image = wp_get_attachment_image_src( $post->id, "full"); ?>
id); ?>" rel="attachment" target="_new">" alt="" />
</div><!-- END photoFull -->
<?php
foreach ( $attachments as $attachment ) {
$specific[$attachment->ID] = $i;
++$i;
}
if($specific[$post->ID] == $count) { ?>
<aside id="seeMore">
<div class="sectionheader"><h2>More Galleries</h2></div>
-
<?php
-
<div class="entryThumb">
">
<?php
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
$image2 = get_image_attachment();
if ( has_post_thumbnail( $post->ID ) ) { ?>
/timthumb.php?src=<?php echo $image[0]; ?>&w=215&h=300&q=80" alt="" />
<? } else { ?>
/timthumb.php?src=<?php echo $image2; ?>&w=215&h=300&q=80" alt="" />
<? } ?>
</div>
<h3>"><?php the_title(); ?></h3>
$galleries = new WP_Query(array(
'posts_per_page' => 4,
'tag' => 'galleries',
'post__not_in' => array($post->post_parent)
));
while ( $galleries->have_posts() ) : $galleries->the_post();
?>
<?php endwhile; wp_reset_query() ?>
<div class="clear"></div>
</aside><!-- END seeMore -->
<? } ?>
</section><!-- END mainContent -->
<aside id="sidebar">
<div id="infoHeader">
<div id="controls">
<div id="prevNext">
<div id="prev"><?php previous_image_link() ?></div>
<div id="count">
<?php echo "{$specific[$post->ID]}/{$count}"; ?>
</div>
<div id="next"><?php next_image_link() ?></div>
</div><!-- END prevNext -->
<div id="closeButton">post_parent); ?>" rev="attachment"></div>
</div><!-- END controls -->
<h1>post_parent); ?>" rev="attachment"><?php the_title(); ?></h1>
</div><!-- END infoHeader -->
<?php the_content();?>
<div class="socialIcons">
- <span class="socicon-facebook">" title="Share on Facebook" target="_blank"></span>
- <span class="socicon-twitter">&text=<?php echo htmlspecialchars(urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8'); ?>:%20<?php the_permalink() ?>&via=mariedenee" target="_blank" title="Tweet This!"></span>
- <span class="socicon-pinterest">&media=<?php echo $att_image[0];?>&description=<?php echo htmlspecialchars(urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8'); ?>" data-pin-do="buttonPin" data-pin-shape="round" title="Pin It!"></span>
- <span class="socicon-tumblr">&caption=<?php the_title(); ?>&source=<?php echo $att_image[0];?>" target="_blank" title="Post on Tumblr"></span>
- <span class="socicon-email">&body=Check this out on The Curvy Fashionista!:%20<?php the_permalink() ?>" title="Share via Email"></span>
</div><!-- END socialIcons -->
<div class="ad_300x250">
<?php echo do_shortcode( '[adrotate group="3"]' ); ?>
</div><!-- END ad_300x250 -->
</aside><!-- END sidebar -->
<?php endwhile; else: ?>
<?php endif; ?>
<?php get_footer(); ?>
What of this would be added in to the existing NewsPaper attachment.php file to help me get the desired gallery layout?
Thanks!
Hi
I looked over the code you provided and even if our theme already have the light box implemented you will need some serious customizations to achieve a similar functionality for the gallery like the one from the indicated link. This is a complex task and unfortunately I can’t provide a solution now. If you need this and you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you as we can’t offer customization services at the moment.
Thanks!