How create own custom smart gallery & shortcode using NextGen Gallery!


For integrate custom Gallery using NexnGen Gallery just follow code given below
You can add JQuery Image gallery in your wordpress site using this code.
/** Custom gallery function **/
function rgallery_func($atts) {
extract(shortcode_atts(array(
'id' => 'no foo',
'bar' => 'default bar'
), $atts));

$ID=$atts[id]; //retrieve NextGen Gallery ID passed in short code

/** Get Main gallery image root path **/

$Qryslug="select path from wp_ngg_gallery where gid='$ID'";
$queryslug = mysql_query($Qryslug);
$aryslug=mysql_fetch_array($queryslug);
$GalleryPath=$aryslug['path'];

/** Get gallery images **/

$Qry="select * from wp_ngg_pictures where galleryid='$ID'  and exclude=0 order by pid desc";
$query = mysql_query($Qry);
$i=0;
if (mysql_num_rows($query) > 0) {

echo ' <div id="gallery">
<div>
</div>

<div>
<div>
<ul>';

while($Arry=mysql_fetch_array($query))
{
$Titlle =stripslashes($Arry['alttext']);
$FileName =$Arry['filename'];
$descr =stripslashes($Arry['description']);
echo '<li>
<a href="'.home_url('/').$GalleryPath.'/'.$FileName.'"  title="'.$Titlle.'">
<img src="'.home_url('/').$GalleryPath.'/thumbs/thumbs_'.$FileName.'"  title="'.$Titlle.'" alt="'.$descr.'">
</a>
</li>';
$i++;
}
echo '</ul>
</div>
</div>
</div>';
} else {
echo '<img src="' . home_url('/') . 'wp-content/themes/suchdesign/images/no-image.jpg">';

}
}

add_shortcode('rgallery', 'rgallery_func');//Just add short code [rgallery id=GalleryID] in your page

 //Add custom JQuery in header

add_action('wp_head','add_jquery_header',5);

function add_jquery_header()

{

echo '<script src="your-root-path/filename"></script>\n';

echo '<script src="your-root-path/filename"></script>\n';

}

For any further enquiry please contact to our support team raghunath.0087@gmail.com

Advertisements

Sr. Software Engineer

Posted in PHP, Wordpress
One comment on “How create own custom smart gallery & shortcode using NextGen Gallery!
  1. davy says:

    very helpful thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s