Support » Plugin: GPX Viewer » Error when displaying categories in admin screen

  • Hi,

    Just as a pointer for those wanting to get this working – and for the writer to add to the next version :

    the reason some people cannot see the categories in the admin screen is a slight code issue within gpx-viewer-admin.php file.

    Currently, the recent version 1.0.7 – uses the following to get the categories :

    // Get categories
    $sql = “SELECT wp_terms.slug,
    FROM wp_term_taxonomy, wp_terms
    WHERE wp_term_taxonomy.taxonomy = ‘category’
    AND wp_terms.term_id = wp_term_taxonomy.term_id
    AND wp_term_taxonomy.parent = 0”;

    Which is fine.. as long as you are using a database table name suffix of ‘wp_’ – when your installation does not, the statement returns zero rows as wp_terms etc doesnt exist.. its [your selected prefix]terms..

    After changing the code to :

    $sql = “SELECT t.slug,
    FROM ” . $wpdb->prefix . “term_taxonomy ta, ” . $wpdb->prefix . “terms t
    WHERE ta.taxonomy = ‘category’
    AND t.term_id = ta.term_id
    AND ta.parent = 0”;

    The statement runs fine on all installations, and categories can be selected when uploading GPX files.



Viewing 1 replies (of 1 total)
  • ip-rob


    This modification didn’t work for me so I went ahead and did it the hard way inserting the prefix into the statement everywhere “wp_” was located. My hosting company uses a different prefix and this resolved the issue.

    	$sql = 	"SELECT ".$wpdb->prefix."terms.slug, ".$wpdb->prefix."
    			FROM ".$wpdb->prefix."term_taxonomy, ".$wpdb->prefix."terms
    			WHERE ".$wpdb->prefix."term_taxonomy.taxonomy = 'category'
    			AND ".$wpdb->prefix."terms.term_id = ".$wpdb->prefix."term_taxonomy.term_id
    			AND ".$wpdb->prefix."term_taxonomy.parent = 0";


Viewing 1 replies (of 1 total)
  • The topic ‘Error when displaying categories in admin screen’ is closed to new replies.