Skip to content

Instantly share code, notes, and snippets.

@VirtuBox
Last active June 6, 2017 22:28
Show Gist options
  • Save VirtuBox/010da692a0efb65a08ec5d61f534d576 to your computer and use it in GitHub Desktop.
Save VirtuBox/010da692a0efb65a08ec5d61f534d576 to your computer and use it in GitHub Desktop.
Remove Query strings and add featured images in WordPress feeds

WordPress Optimization

Remove Query strings on static assets

Add featured images in wordpress feeds

Add this code in your theme functions.php

//remove queries from static assets
function _remove_script_version( $src ){
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

// Include thumbnails is the RSS feed
function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) .
'</p>' . get_the_content();
}
return $content;
}
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment