WordPress.org

Ready to get started?Download WordPress

Forums

Calling a Nextgen gallery from my page template (2 posts)

  1. AndreasWik
    Member
    Posted 2 years ago #

    Let me start off by saying I did search and read through the couple of forum posts I found regarding this subject, but it didn't really do it for me, so here we go.

    How do I activate a Nextgen gallery in my template file? Step-by-step would be great. Do I need to activate widgets and stuff too?

    /Andreas

  2. jimmerd
    Member
    Posted 2 years ago #

    I'm not real clear on what you're trying to do. There should be no need to activate NextGen in template files UNLESS you want the gallery to show up outside the loop.

    To put a gallery in a post or page, you just use the shortcode as outlined here:
    http://nextgen-gallery.com/gallery-page/nggallery/page-2/

    Once NextGen is installed and activated as a plugin, you can drag a widget to any active sidebar.

    I tend to use the NextGen Smooth plugin and here's how I implemented in a modified TwentyTen theme. The following goes in the header.php and replaces TwentyTen's header image -- on the home page only -- with a Smooth Gallery of the same size. This code should work fine with NextGen by itself.

    And now that I look at, I wonder why the shortcode works within PHP and outside the loop. Hmmm.

    <?php
    // Check if this is a post or page, if it has a thumbnail, and if it's a big one
    	if ( is_front_page() ) :
      $homeslides = "[smooth=id: 1; width:940; height:198; timed:true; arrows:false; carousel:false; links:false; info:false; align:center; frames:true; delay:9000; transition:fade;]";
      smooth_show($homeslides);
      elseif ( is_singular() &&
    							has_post_thumbnail( $post->ID ) &&
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
    							$image[1] >= HEADER_IMAGE_WIDTH ) :
    						// Houston, we have a new header image!
    						echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
    					else : ?>
    						<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    					<?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.