Support » Plugins » [Plugin: NextGEN Gallery] Clean/SEO URL solution

  • Here’s a very quick hack to demo how easy it would be to have clean, SEO friendly URL structure for *all* albums and galleries without having to resort to:


    1. Gallery > Options > General Options > Activate permalinks [ empty ] do not tick this box

    2. Create a new Page to act as gallery main slug (this must match 1st segment in rewrite rule, see below):


    3. Insert the ngg shortcode (so nextgen code is run)

    [album id=1 template=compact]

    4. Visit URL:

    File: nggfunctions.php

    Line #330 in function nggShowAlbum()

    // $_GET from wp_query
        $gallery  = get_query_var('gallery');
        $album    = get_query_var('album');
        global $wpdb;
        $album_result = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggalbum WHERE name = '%s'", $album) );
        $gallery_result = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggallery WHERE name = '%s'", $gallery ) );
        $album = $album_result->id;
        $gallery = $gallery_result->gid;

    File: THEME/functions.php

        // Remember to flush_rules() when adding rules
        function flushRules()
            global $wp_rewrite;
        // Adding a new rule
        function wp_insertMyRewriteRules($rules)
            $newrules = array();
            $newrules['(gallery)/([a-z\-]*)/([a-z\-]*)$'] = 'index.php?pagename=$matches[1]&album=$matches[2]&gallery=$matches[3]';
            return $newrules + $rules;
        // Adding the id var so that WP recognizes it
        function wp_insertMyRewriteQueryVars($vars)
            array_push($vars, 'id');
            return $vars;

Viewing 1 replies (of 1 total)
  • Stencil,

    This appears to be exactly what I’ve been searching for. Except it doesn’t seem to work. Can you offer a more complete walk-through of the solution? I’ve changed:
    to read
    I have an existing page called /portfolio/. But the thumbnail links on this page still appear as ../portfolio/?album=7

    Can you help me sort out what’s missing? Your help is very much appreciated!

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: NextGEN Gallery] Clean/SEO URL solution’ is closed to new replies.