• Resolved keithhp1

    (@keithhp1)


    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, wp_terms.name
    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, t.name
    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.

    Thanks.

    Keith.

Viewing 1 replies (of 1 total)
  • 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."terms.name
    			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";
    

    Rob

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