Leverage browser caching & Enable Compression

# Enable Compression
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
</IfModule>
<IfModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>

# Leverage Browser Caching
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpg "access 1 year"
  ExpiresByType image/jpeg "access 1 year"
  ExpiresByType image/gif "access 1 year"
  ExpiresByType image/png "access 1 year"
  ExpiresByType text/css "access 1 month"
  ExpiresByType text/html "access 1 month"
  ExpiresByType application/pdf "access 1 month"
  ExpiresByType text/x-javascript "access 1 month"
  ExpiresByType application/x-shockwave-flash "access 1 month"
  ExpiresByType image/x-icon "access 1 year"
  ExpiresDefault "access 1 month"
</IfModule>
<IfModule mod_headers.c>
  <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
  Header set Cache-Control "max-age=2678400, public"
  </filesmatch>
  <filesmatch "\.(html|htm)$">
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  </filesmatch>
  <filesmatch "\.(pdf)$">
  Header set Cache-Control "max-age=86400, public"
  </filesmatch>
  <filesmatch "\.(js)$">
  Header set Cache-Control "max-age=2678400, private"
  </filesmatch>
</IfModule>
274 Views

Remove Query Strings from Static Resources

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 );
615 Views

Magnific Popup – Remove related youtube videos on popup

<script>
jQuery(window).load(function(){
    jQuery('a[href*="youtube.com/watch"]').magnificPopup({
       type: 'iframe',
           iframe: {
               patterns: {
                   youtube: {
                       index: 'youtube.com', 
                       id: 'v=', 
                       src: '//www.youtube.com/embed/%id%?rel=0&autoplay=1'
                    }
               }
           }   
     });      
});
</script>
2,091 Views

Bootstrap 4 tabs

<ul class="nav" role="tablist">
	<li class="nav-item"><a class="nav-link active" href="#tab-1" role="tab" data-toggle="tab">Tab 1</a></li>
	<li class="nav-item"><a class="nav-link" href="#tab-2" role="tab" data-toggle="tab">Tab 2</a></li>
</ul>

<div class="tab-content">
	<div role="tabpanel" class="tab-pane fade in active show" id="tab-1">
		
	</div>
	<div role="tabpanel" class="tab-pane fade" id="tab-2">
		
	</div>
</div>
2,189 Views

Shortcode inside custom post with pagination

function snowreports_shortcode($atts){
    extract( shortcode_atts( array(
        'count' => 10,
    ), $atts) );
    $i = 0;
    $q = new WP_Query(
        array(
            'posts_per_page' => $count, 
            'post_type' => 'posttype', 
            'paged'     => get_query_var('paged'),
        )
    );      
         
    $list = '<div class="custom-post-list">';
    while($q->have_posts()) : $q->the_post();
        $idd = get_the_ID();
        $i++;
        $custom_field = get_post_meta($idd, 'custom_field', true);
        $post_content = get_the_excerpt();
        $list .= '
        <div class="single-post-item">
            <h2><a href="'.get_permalink().'">' .do_shortcode( get_the_title() ). '</a></h2>
            '.wpautop( $post_content ).'
        </div>
        ';        
    endwhile;
    
    $total_pages = $q->max_num_pages;
    $big = 999999999;
    if ($total_pages > 1){  
        $current_page = max(1, get_query_var('paged'));  
        $list.= '<nav class="page-nav">';  
        $list.= paginate_links(array(  
            'base'      => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
            'format'    => '?paged=%#%',  
            'current'   => $current_page,  
            'total'     => $total_pages,  
            'prev_text' => 'Prev',  
            'next_text' => 'Next'  
        ));  
        $list.= '</nav>';  
    }     
    
    
    $list.= '</div>';
    wp_reset_query();
    return $list;
}
add_shortcode('snowreports', 'snowreports_shortcode');
22,955 Views
Page 1 of 2712345...1020...Last »