New home › Forums › Pro Add-on › General queries › Change/reset categories id's
Tagged: categories, category, database, ID
- This topic has 13 replies, 1 voice, and was last updated 2 years, 4 months ago by Steven.
-
AuthorPosts
-
July 13, 2017 at 1:09 pm #28626Eva RennenMember
Hi!
So far the plugin has been working great, thanks for all the work!I am using the Pro version and I have been playing around with categories and I now want to start over. Because I will be uploading a lot of markers it is easiest if I can start with category id 1 again. Now it starts from 14. How can I reset the id’s or manually change them? I saw somewhere on the forum it should be done in the database but looking at the files with FileZilla I don’t know where to find them.
Can you help me locate them so I can change them? Also, I have markers in the map now that have old categories. I have removed the categories but they still show on the backend. Will that be a problem?
thanks a lot!
Eva
July 13, 2017 at 1:15 pm #28627PerryModeratorHi Eva,
Thank you for getting hold of us.
This question was actually asked earlier this week, what you would need to do is go to your cPanel and use phpMyAdmin to access the database – it can’t be reached through the FTP normally.
You will need to adjust the IDs in the database there, and if you want new categories to be consecutive you’ll need to update the category tables AUTO_INCREMENT too.
Additionally, if you have already categorised your markers, you’ll need to alter the category field in your marker table (usually wp_wpgmza) to match the new category IDs. You could do this with string replacement, but if it’s possible I’d recommend doing it manually instead.
The redundant categories won’t cause any problems, you can just remove them from the markers or leave them there, it won’t cause any issues.
Is there anything else I can help you with?
Kind regards
– PerryJuly 13, 2017 at 1:40 pm #28628Eva RennenMemberAhh thanks so much for the fast reply Perry, works great. Just a question about the order by id instead of alphabetical. Category table id is set to auto increment and I saw a previous reply on how to change the order to id, but this was for dropdown. I am using checkboxes.
What would be the best way to solve this?thanks in advance,
Eva
July 13, 2017 at 1:44 pm #28629Eva RennenMemberedit: I found the line of code for the checkbox but when I changed ORDER BY ‘category_name’ ASC to ORDER BY ‘id’ ASC and loaded my page, no categories could be found
July 13, 2017 at 1:45 pm #28630PerryModeratorHi Eva,
The best thing to do would be to find the query that fetches the categories and then append/change the ORDER BY to category_name
I just saw your second reply, that should definitely work, could you show me the whole query please?
Kind regards
July 13, 2017 at 1:48 pm #28631Eva RennenMemberyou mean this?
}
function wpgmza_pro_return_category_checkbox_list($map_id,$show_all = true,$array = false) {
global $wpdb;
global $wpgmza_tblname_categories;
global $wpgmza_tblname_category_maps;
if ($array) { $array_suffix = “[]”; } else { $array_suffix = “”; }
$sql = “SELECT * FROM$wpgmza_tblname_category_maps
LEFT JOIN$wpgmza_tblname_categories
ON $wpgmza_tblname_category_maps.cat_id = $wpgmza_tblname_categories.id WHERE (map_id
= ‘$map_id’ ORmap_id
= ‘0’ ) ANDactive
= 0 ANDparent
= ‘0’ ORDER BYid
ASC”;July 13, 2017 at 2:26 pm #28633PerryModeratorHi Eva,
Sorry I misunderstood, I can see now that you want to sort by ID not by category_name. The reason this fails is because the ID column is ambiguous. If you change the query to ORDER BY $wpgmza_tblname_categories.id then it will work
Kind regards
July 13, 2017 at 3:00 pm #28638Eva RennenMemberHoi Perry,
unfortunately it still says ‘no categories found’ above my map..July 13, 2017 at 3:02 pm #28640PerryModeratorHi Eva,
You must have a syntax error somewhere in there or an otherwise malformed query
If you can give me FTP access to the site in question I can carry out these changes for you,
If that’s not possible could you please show me the query now that you’ve made those changes?
Kind regards
– PerryJuly 13, 2017 at 3:14 pm #28642Eva RennenMemberThis reply has been marked as private.July 13, 2017 at 3:26 pm #28643PerryModeratorHi Eva,
It’s because you’ve put that ORDER BY column in back ticks `
They go around the field name, but not the table name. If you remove the two backticks around $wpgmza_tblname_categories.id then it will work!
Kind regards
– PerryJuly 13, 2017 at 3:35 pm #28644Eva RennenMemberHi Perry,
thanks so much, it worked!
All the best,
EvaJuly 13, 2017 at 3:37 pm #28645PerryModeratorThis reply has been marked as private.May 5, 2021 at 4:00 pm #68744sHabib123ParticipantHi Perry,
I am trying to get a controlled map by linking it to a specific marker, and the approach which is recommended on the linked article is via using marker-id. But this approach is not feasible for me, because I am updating the markers on a daily schedule, which changes the id of the marker, on every single import. I think that is because of auto-increment. Can you kindly guide me, how to import the markers with consistent IDs or how to control the map link of a marker with some other parameter?
Using GET variables to Control your Map
Thank you!
Regards,
SaudMay 7, 2021 at 1:24 pm #68790StevenModeratorHi there,
Thank you so much for getting in touch.
We see you have opened a new thread on the forum so to avoid any confusing, our team will kindly be responding to that thread.
For your reference, please find a link to the thread below:
– https://www.wpgmaps.com/forums/topic/how-to-control-map-on-a-new-page-by-linking-into-a-specific-marker/Kindest Regards,
Steve -
AuthorPosts
- You must be logged in to reply to this topic.