NextGEN Gallery
Get ID from "Page link to" (3 posts)

  1. Pancho Perez
    Posted 3 years ago #

    I know it works when you set for a new page and then it create a gallery inside that page. But what happend when the "Page link to" is already created?.

    I use the gallery shortocode with do_shortcode so then in the page or CPT is a metabox where I put the gallery id to relate, and I´m guessing, How can I get the ID selected in the gallery as a "Page link to"?, it´s possible?

    Thanx for any help or advice :)


  2. Pancho Perez
    Posted 3 years ago #

    I create a new gallery template, inside my theme folder is the folder /nggallery/gallery-slide.php, here I create a link for the images using the ID of the "Page link to"
    <a href="<?php bloginfo('url'); ?>/?p=<?php echo $gallery->pageid ?>"> it works, but is not exaclty what I need.

    If you want all images link to the "Page link to", but in my case is not. I use NGG Custom Fields Plugin, resolving the link and gallery like this:

    <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($gallery)) : ?>
    	<div id="hotel-slider">
    	<?php foreach ( $images as $image ) : ?>
    		<div data-caption="#htmlCaption-<?php echo $image->pid ?>">
    			<a href="<?php echo $image->ngg_custom_fields["Link"]; ?>">
    				<img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->imageURL ?>" />
     	<?php endforeach; ?>
    	<?php foreach ( $images as $image ) : ?>
    		<div class="orbit-caption" id="htmlCaption-<?php echo $image->pid ?>">
    			<?php echo $image->alttext ?>
     	<?php endforeach; ?>
    <?php endif; ?>

    and I insert the gallery using the shortcode inside the theme code:

    <?php if ( get_post_meta( get_the_ID(), '_ola_hotel_gallery', true) ): ?>
    		<?php echo do_shortcode('[nggallery id='.get_post_meta( get_the_ID(), '_ola_hotel_gallery',true ).' template=slide]');?>
    <?php endif; ?>

    My PHP/MySQL skills are limited so I don´t know how to use <?php echo $gallery->pageid ?> outside the new NGG template file.

  3. Pancho Perez
    Posted 3 years ago #

    the correct way to insert the "Page link to" url was
    <?php echo get_permalink($gallery->pageid); ?>

    But I´m keep searching how to take the ID inside of the do_shortcode :(

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • NextGEN Gallery
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic