I have a use case where I need to disable comments on posts in WordPress where the last comment was more than one year, or 365 days, ago. Posts can be found with this query: SELECT p.ID, p.post_title, p.post_date, p.comment_status, p.`ping_status` FROM wp_posts AS p WHERE p.ID IN ( SELECT c.comment_post_ID FROM wp_comments AS c
WordPress Multisite: Global options that can be overridden per site
I recently ran into a situation where a WordPress Multisite install needed to have some options replicated across each site, both new and existing. It also needed to be able to override the options per site if so desired. The solution is fairly trivial. Setup the options page in wp-admin. Ensure it exists on all subsites
WordPress: Add category to permalink and redirect old permalinks
Occasionally you run across a situation where a website permalink structure needs to be changed from what it has been to a new structure. Most sites that have been public will have links to them from other websites that need to properly redirect to the new permalink structure. Removing an element from the permalink structure
Prevent WordPress plugins from requesting updates
Ever need to “lock” a plugin into a specific version and do not want it showing in the updates list and getting accidentally updated? This quick snippet allows you to specify a plugin(s) that should not appear in the update list. This will effectively block them from updating through WordPress itself. Manual updates/changes to the
Getting social media shares with php
Quick snippets to help me (and maybe you!) remember how to quickly and easily get share counts from social networks. What other networks would you like to see? Facebook [php] function facebook_share_count( $post_id ) { $api = "https://graph.facebook.com/"; $url = $api . urlencode( get_permalink( $post_id ) ); $response = wp_remote_get( $url ); if( is_wp_error( $response