Code Snippets
Recent Code Snippets
WordPress Update URLS
PHP/* Replaces URL in WordPress Home and Site URL in wp_options */ UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsite.com', 'http://www.newsite.com')…
January 30, 2023
Add Extra Media Type Filters to the WordPress Media Manager
PHP//Add Extra Media Type Filters to the WordPress Media Manager function modify_post_mime_types( $post_mime_types ) { // select the mime type,…
January 30, 2023
Improve WP Query performance
PHP $args = array( // Normal query goes here // 'no_found_rows' => true, // counts posts, remove if pagination required…
January 30, 2023
Limit Tags to 3 per Post
PHP//* Limit tags to three per post... add_filter( 'term_links-post_tag', 'wpdevco_limit_post_tags' ); function wpdevco_limit_post_tags( $terms ) { return array_slice( $terms, 0,…
January 30, 2023
Youtube Schema Jetpack
PHP <?php if ( ( isset( $url['path'] ) && '/videoseries' == $url['path'] ) || isset( $qargs['list'] ) ) { $html…
January 30, 2023
Jetpack Custom Fallback Image
PHPfunction jeherve_custom_image( $media, $post_id, $args ) { if ( empty( $media ) ) { $permalink = get_permalink( $post_id ); $url…
January 30, 2023
Jetpack: Add Related Posts to your RSS feed
PHP/** * Add Jetpack Related Posts to RSS feed. * * @see https://wordpress.org/support/topic/2927523 * * @param string $content Post content.…
January 30, 2023
Stop WordPress sending anything but essential data during the update check
PHPfunction wp_update_privacy( $query ) { unset($query['php']); unset($query['mysql']); unset($query['local_package']); unset($query['blogs']); unset($query['users']); unset($query['multisite_enabled']); unset($query['initial_db_version']); return $query; } add_action( 'core_version_check_query_args', 'wp_update_privacy' );
January 30, 2023
Get all Metakeys
PHPfunction get_all_meta_keys(){ global $wpdb; $table = $wpdb->prefix . 'postmeta'; $results = $wpdb->get_results("SELECT DISTINCT meta_key FROM $table;"); var_dump($results); }
January 30, 2023
PostmarkApp Headers for Gravity Forms
PHP/** * Postmark Headers for Gravity Forms. * * @param [type] $email Email. * @param [type] $message_format Message Format. *…
January 30, 2023