Tom J Nowell

United Kingdom

tomjn.com

Age: 26

I'm a fulltime WordPress Developer at Code For The People in the UK. I also build RTS AIs & attend WordPress/design conferences.

Any questions please say hello, I can normally be found in the WPSE chat ( link in the top header ).

20h
revised Register Script in Plugin Widget
deleted 10 characters in body
20h
answered Register Script in Plugin Widget
20h
revised Register Script in Plugin Widget
deleted 10 characters in body
21h
comment Custom Wordpress Table wpdb
I'd also add that you shouldn't hardcode the wp_ prefix, not all sites use wp_ and it breaks multisite support. Use $wpdb->prefix instead. Also @cybmeta it's not a race to answer first, it's a race to answer best =]
21h
comment Custom Wordpress Table wpdb
You shouldn't be calling the mysql_ functions in WordPress, use $wpdb, or in general, as the mysql extension is deprecated, use PDO or Mysqli instead if wpdb isn't available
1d
comment How do I deliver posts based on user geolocation
Also keep in mind that people move, if I pull up your site on a plane/on holiday/while visiting a friend/in a car, I'm not going to get relevant results, especially if I'm google and google can only see the page for their data centres location
1d
comment How do I deliver posts based on user geolocation
There is no bullet proof solution, in the past I've used the javascript geolocation API. Doing it server-side runs the risk that you may mis-locate someone and they can't access the correct page as your server thinks they're elsewhere or can't locate them. But at the very least validate the data you do receive for error codes and empty values.
2d
comment Offset WP_Query by negative 1
Importantly, explain why
2d
comment How do I deliver posts based on user geolocation
In much the same way that paper walls make a terrible house, it does not prevent your query from working but it's rarely a good idea. Of particular note however, you make no attempt to check errors. That service shows "" as my region here in the UK, which isn't handled by your code, nor are 404's, 500's, or network errors handled. You also make no attempt to define what you expect $georegion to be, is it a slug? "washington"? or a term ID? or a country code? This is very important but you gloss over it
2d
comment How do I deliver posts based on user geolocation
A lot of servers disable it from making remote requests for security reasons, using the WordPress APIs allows plugins to interact, and the fallbacks WordPress provides ( e.g. Curl ) to be used. See here for more information
2d
comment Woo commerce taxonomy multiple category types
What you're looking for is called custom taxonomies, but I will say woocommerce specific things are off topic here, and your question has a lot of things in it, it's too broad. The auto-fabricated category description is a huge question all on its own
2d
comment How do I deliver posts based on user geolocation
You shouldn't be using file_get_contents to make remote requests, use the WP_HTTP API or a library such as guzzle
Nov
23
comment post_type_exists keeps returning false
Plugin activation is a popular one, usually the user needs to visit the permalink page and the rules are flushed automatically
Nov
23
answered post_type_exists keeps returning false
Nov
21
comment attach image from library to post with wp_insert_attachment
If they are in the media library then they are attachment posts, do you mean you copy pasted or transferred the files there rather than uploading them via the admin interface? If they show in the media library they are already attachments
Nov
21
comment Reset/Reorder posts ID in the MySQL wp_posts table
It is a lot of work that will need repeating anytime a post, revision, or media file is deleted, with no guarantee it will be foolproof
Nov
21
comment Reset/Reorder posts ID in the MySQL wp_posts table
Those are not small numbers, 2 factor auth numbers used by Google and Banks are 6 digits, and science says we can hold between 5 and 7 digits in our head fine. What you actually have is a usability issue, making your users remember numbers is an awful, awful idea, and will not scale. What happens when you have 9,999 posts? Eitherway what you're trying to do requires a lot of MySQL knowledge, you'd be better off asking how to implement a proper user interface with a dropdown or an autocomplete to pick a post rather than going with the copy paste a number scheme
Nov
21
comment attach image from library to post with wp_insert_attachment
If the file is in the uploads folder, then it should already have an attachment post. Also when you're calling wp_update_post, what is specifying 'ID' => $attach_id intended to DO?
Nov
20
comment Reset/Reorder posts ID in the MySQL wp_posts table
I've seen plenty of sites with a lot more than 7000 posts, I very much doubt you will get the performance gains you expect from doing this, and keep in mind you will need to update all the post meta tables, the term relationships, any options that store post IDs, clear all your object caches, transients, and any URLs that contain post IDs will no longer work or lead to the wrong location. Your post IDs are as unique as they ever will be, a gap doesn't change that ( and gaps will happen once a post is deleted anyway ). I suspect micro-optimization
Nov
20
comment Upload a json file in php
Can you expand your code a little so we can see the context? It's not clear which hook the above is running on or what comes before and after it
1 2 3 4 5