Support » Plugins » HOW TO add gallery/album name/description to page title/page body

  • Resolved Libor Jelinek


    Dear WP friends,
    I would like to save your time (maybe your souls :-)) and provide you my approach how to hack great NextGEN gallery to get rid annoying Album 2 >> Gallery 3 page titles and absence of gallery name and description on page body itself.

    1) Principle
    I’ve inspired by Madjax in

    2) (Example of) page title
    Open wp-content/plugins/nextgen-gallery/lib/rewrite.php, locate method (function) rewrite_title(). Mark as comment, delete, or add nearly before end before return $title. Past (and customize) code:

    global $wpdb;
    		$gallerycontent = $wpdb->get_row("SELECT * FROM $wpdb->nggallery WHERE gid = '$gallery' ");
    		$albumcontent = $wpdb->get_row("SELECT * FROM $wpdb->nggalbum WHERE id = '$album' ");
    		if(!empty($gallerycontent->title)) {
    			$new_title = ' - '.$gallerycontent->title.' ('.$albumcontent->name.')';
    			$title = $new_title . $title;

    3) (Example of) gallery name and description in page body
    Firsly I created own page template for page where [album=N] shorcode is placed. Then in template file (e.g. photogallery.php) place (similar to previous) this code where you wish have gallery name and description echoed:

    global $wpdb;
    	$gallerycontent = $wpdb->get_row("SELECT title, galdesc FROM $wpdb->nggallery WHERE gid = '$gallery' ");
    	$albumcontent = $wpdb->get_row("SELECT name FROM $wpdb->nggalbum WHERE id = '$album' ");
    	if(!empty($gallerycontent->title)) {
    		$title = $gallerycontent->title.' <small>('.$albumcontent->name.')</small>';
    		echo '<h2>'.$title.'</h2>';
    		echo $gallerycontent->galdesc;

    (of course inside <?php and ?>)

    Hope that this brief how-to helped you!

  • The topic ‘HOW TO add gallery/album name/description to page title/page body’ is closed to new replies.