remove default image sizes from wordpress theme

If you want to disable or remove default image sizes from wordpress theme. Than use code in them file. wordpress creates more than five images while upload.

remove default image sizes from wordpress theme

Every custom wordpress theme has their different thumbnail sizes defined. When we upload any image to wordpress,  By default wordpress create four resized images. Means when we upload image, wordpress upload five images on server. Which is not necessary and unwanted. If your theme added, custom thumbnail sizes then it create more than five images and upload on server.

Tip: Whenever you change wordpress theme than regenerate thumbnails in wordpress website.

Use following code in functions.php file.


// Set default thumbnail size
set_post_thumbnail_size( 150, 150 );
function wpapi_filter_image_sizes( $sizes) {
unset( $sizes['medium']);
unset( $sizes['large']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'wpapi_filter_image_sizes');

We used above code in our wordpress theme. Now while image upload, we are storing only three images on server. which saves the disk space.

If you want to remove unwanted image sizes from wordpress theme. Sometime you need the original and thumbanil image only. But many wordpress themes creates the multiple image version in your site which is not useful. Although it is possible to prevent the creation of default image sizes by changing their dimension settings to ’0′ in Dashboard > Settings > Media, these image sizes will still appear in the list of sizes in the Media Uploader.

Why use above method in wordpress theme

Due to custom thumbnail sizes your server images data will always increase. Some image sizes are not important for bloggers and website. So why to create unwanted images and store on server.

remove default image sizes from wordpress theme
remove default image sizes from wordpress theme

You can always full sized image in website. Just fixing image sizes use following CSS code.

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]


img{max-height:100% !important;max-width:100% !important}

[/viral-lock]

If you use above code in style.css file than your wordpress UI will not break.

how to create custom wordpress shortcodes

wordpress shortcodes are used in custom themes and plugins. so here in this wordpress tutorial, we will show, how to create custom shortcodes in wordpress theme.

how to create custom wordpress shortcodes

We want use wordpress shortcode in text widget and we can use shortcodes in wordpress posts. Here we will show how easily you can create wordpress shortcodes and use it.

Here using following code you can create simple shortcode. You just need to copy and paste following code in functions.php file (theme folder). If you cant to use shortcode for plugin then add this code in plugin file.

//[simple_shortcode]
function simple_shortcode_function( $atts ){
    return "foo and bar";
}
add_shortcode( 'simple_shortcode', 'simple_shortcode_function' );

Using attributes you can create short code as follows:

// [attribute_sample attr1="attr1-value"]
function attribute_sample_function( $atts ) {
    $a = shortcode_atts( array(
        'attr1' => 'something text',
        'attr2' => 'something text else',
    ), $atts );

    return "foo = {$a['foo']}";
}
add_shortcode( 'attribute_sample', 'attribute_sample_function' );

Three parameters are passed to the shortcode callback function. You can choose to use any number of them including none of them.

  • $atts – an associative array of attributes, or an empty string if no attributes are given
  • $content – the enclosed content (if the shortcode is used in its enclosing form)
  • $tag – the shortcode tag, useful for shared callback functions

Here is detailed example.

function subscribe_shortcode( $atts, $content = null ) {

$our_attr =  shortcode_atts( array(
        'subtype' => 'RSS',
        'subtypeurl' => 'http://feeds.feedburner.com/wordpressapi',
    ), $atts ) ;

    return sprtinf( ' . $content . ' <a href="%1$s">by %2$s</a>.',
        esc_url( $our_attr['subtype'] ),
        esc_html( $our_attr['subtypeurl'] )
    );
 
    return '<span class="caption">' . $content . '</span>';
}
add_shortcode( 'rssfeed_subscribe', 'subscribe_shortcode' );

 

Above we created simple feedburner subscription short code. You can use above short code as follows:
[rssfeed_subscribe subtype=”RSS”]
Be sure to subscribe to future WordPress API updates
[/rssfeed_subscribe]

how to create custom wordpress shortcodes
how to create custom wordpress shortcodes

add feedburner email subscription popup wordpress without plugin

Here in this wordpress tutorial, we shown, how to add feedburner email subscription wordpress without plugin. Feedburner is free email subscription service by google feedbuner. You can open account using Feedbuner website.

Feedburner is free option, Feedburner is great email subscription tool, Still as compare to other paid services. Feedburner is good but I miss many features when I compare to other paid.

Why Email Subscription Popup is important.

There are many paid services offered email subscription popup functionality. They said, They will boost your your site visibility and subscribers. But you can get email subscription popup for free so, why need to pay. Google is given reputed feedburner service.

Note: The Google Feedburner APIs are no longer available.

But not to worry, google still not going to stop feedburner email subscription free service.

add feedburner email subscription popup wordpress without plugin

Here we given code for creating feedburner subscription popup in your wordpress theme. You just need create subscription.php file in theme folder and put following code in that file.


<style type="text/css">
    #subscribe-button { float: left; position: fixed; bottom: 5%; left: 0; z-index: 999; }
    #subscribe-widget { display:none; }
    /* Overlay */
    #btnt-overlay { background-color:#000; }
    /* Container */
    #btnt-container { min-height:350px; min-width:500px; color:#222; background-color:#fff; border:4px solid #ddd; }
    #btnt-container .btnt-data { padding:8px; }
    #btnt-container a.btntCloseImg { background:url(http://3.bp.blogspot.com/-V2A37T0PQ24/U3IuYpfg4DI/AAAAAAAAC_8/YzHEp7rFzSc/s1600/close.PNG) no-repeat; width:25px; height:29px; display:inline; z-index:3200; position:absolute; top:-15px; right:-16px; cursor:pointer; }
    #description { color: #AAAAAA; font-family: times New Roman; font-size: 25px; font-style: italic; }
    #description img { float: left; height: 80px; padding: 0 25px 0 10px; width: 80px; }
    #btntfollowForm { padding: 15px; }
    #btntfollowForm p { margin: 0 0 10px; }
    #btntfollowForm input:not([type="checkbox"]){ width: 93%; margin-top: 4px; margin-bottom: 20px; padding: 10px 5px 10px 25px; border: 1px solid rgb(178, 178, 178); -webkit-appearance: textfield; -webkit-box-sizing: content-box; -moz-box-sizing : content-box; box-sizing : content-box; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; -webkit-box-shadow: 0px 1px 4px 0px rgba(168, 168, 168, 0.6) inset; -moz-box-shadow: 0px 1px 4px 0px rgba(168, 168, 168, 0.6) inset; box-shadow: 0px 1px 4px 0px rgba(168, 168, 168, 0.6) inset; -webkit-transition: all 0.2s linear; -moz-transition: all 0.2s linear; -o-transition: all 0.2s linear; transition: all 0.2s linear; }
    #btntfollowForm input:not([type="checkbox"]):active,
    #btntfollowForm input:not([type="checkbox"]):focus{ border: 1px solid rgba(91, 90, 90, 0.7); background: rgba(238, 236, 240, 0.2); -webkit-box-shadow: 0px 1px 4px 0px rgba(168, 168, 168, 0.9) inset; -moz-box-shadow: 0px 1px 4px 0px rgba(168, 168, 168, 0.9) inset; box-shadow: 0px 1px 4px 0px rgba(168, 168, 168, 0.9) inset; }
    #btntfollowForm .button input{ background: none repeat scroll 0 0 #3D9DB3; border: 1px solid #1C6C7A; border-radius: 3px 3px 3px 3px; box-shadow: 0 1px 6px 4px rgba(0, 0, 0, 0.07) inset, 0 0 0 3px #FEFEFE, 0 5px 3px 3px #D2D2D2; color: #FFFFFF; cursor: pointer; font-family: 'Arial Narrow',Arial,sans-serif;   font-size: 24px; margin-bottom: 10px; padding: 8px 5px; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); width: 30%; float: right; }
    #btntfollowForm .button input:hover{ background: #4ab3c6; text-decoration: none; }
    #btntfollowForm .button input:active,
    #btntfollowForm .button input:focus{ background: rgb(40, 137, 154); position: relative; top: 1px; border: 1px solid rgb(12, 76, 87); -webkit-box-shadow: 0px 1px 6px 4px rgba(0, 0, 0, 0.2) inset; -moz-box-shadow: 0px 1px 6px 4px rgba(0, 0, 0, 0.2) inset; box-shadow: 0px 1px 6px 4px rgba(0, 0, 0, 0.2) inset; }
    .btntFollowFooter { text-align: center; font: 10px Tahoma, Helvetica, Arial, Sans-Serif; padding: 7px 0; margin-top: 80px; text-shadow: 0px 2px 3px #555; position: absolute; width: 500px; }
    .btntFollowFooter a { color: #222; text-decoration: none; }
    .btntFollowFooter a:hover { color: #fff; }
    <!--[if lt IE 7]>
    #btnt-container a.btntCloseImg { background:none; right:-14px; width:22px; height:26px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://images.digcms.com/close.png',sizingMethod='scale'); }
    #btntfollowForm  input{ padding: 10px 5px 10px 32px; width: 93%; }
    #btntfollowForm  input[type=checkbox]{ width: 10px; padding: 0; }
    <![endif]-->
</style>
<div id="subscribe-button">
    <a class="subscribe" href="#"><img style="max-width:100px" src="http://images.digcms.com/trigger-mail-icon.png" alt="subscribe" /></a></div>
<div id="subscribe-widget">
    <div id="btntfollowForm">
        <img alt="Subscribe" border="0" float="center"
             src="http://images.digcms.com/Subscribe-Via-Email.png" />
        <div id='description'>
            <img alt="email" border="0" src="http://images.digcms.com/Mail.png" />Subscribe to our mailing list to get the updates to your email inbox...</div>
        <form action="http://feedburner.google.com/fb/a/mailverify" method="post" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=wordpressapi', 'popupwindow', 'scrollbars=yes,width=550,height=520');
                return true" target="popupwindow">
            <input name="email" placeholder="Enter Your Email..." required="required" type="text" /><input name="uri" type="hidden" value="wordpressapi" /><input name="loc" type="hidden" value="en_US" />
            <div class="button">
                <input type="submit" value="Subscribe" /></div>
        </form>
    </div>
    </div>
<script type="text/javascript">
    (function(d){var k=d.browser.msie&&parseInt(d.browser.version)===6&&typeof window.XMLHttpRequest!=="object",m=d.browser.msie&&parseInt(d.browser.version)===7,l=null,f=[];d.modal=function(a,b){return d.modal.impl.init(a,b)};d.modal.close=function(){d.modal.impl.close()};d.modal.focus=function(a){d.modal.impl.focus(a)};d.modal.setContainerDimensions=function(){d.modal.impl.setContainerDimensions()};d.modal.setPosition=function(){d.modal.impl.setPosition()};d.modal.update=function(a,b){d.modal.impl.update(a,
b)};d.fn.modal=function(a){return d.modal.impl.init(this,a)};d.modal.defaults=
{appendTo:"body",focus:true,opacity:50,overlayId:"btnt-overlay",overlayCss:{},containerId:"btnt-container",containerCss:{},dataId:"btnt-data",dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:false,autoPosition:true,zIndex:1E3,close:true,closeHTML:'<a class="btntCloseImg" title="Close"></a>',closeClass:"btnt-close",escClose:true,overlayClose:false,position:null,
persist:false,modal:true,onOpen:null,onShow:null,onClose:null};d.modal.impl={d:{},init:function(a,b){var c=this;if(c.d.data)return false;l=d.browser.msie&&!d.boxModel;c.o=d.extend({},d.modal.defaults,b);c.zIndex=c.o.zIndex;c.occb=false;if(typeof a==="object"){a=a instanceof jQuery?a:d(a);c.d.placeholder=false;if(a.parent().parent().size()>0){a.before(d("<span></span>").attr("id","btnt-placeholder").css({display:"none"}));c.d.placeholder=true;c.display=a.css("display");if(!c.o.persist)c.d.orig=
a.clone(true)}}else if(typeof a==="string"||typeof a==="number")a=d("<div></div>").html(a);else{alert("btnt Error: Unsupported data type: "+typeof a);return c}c.create(a);c.open();d.isFunction(c.o.onShow)&&c.o.onShow.apply(c,[c.d]);return c},create:function(a){var b=this;f=b.getDimensions();if(b.o.modal&&k)b.d.iframe=d('<iframe src="javascript:false;"></iframe>').css(d.extend(b.o.iframeCss,{display:"none",opacity:0,position:"fixed",height:f[0],width:f[1],zIndex:b.o.zIndex,top:0,left:0})).appendTo(b.o.appendTo);
b.d.overlay=d("<div></div>").attr("id",b.o.overlayId).addClass("btnt-overlay").css(d.extend(b.o.overlayCss,{display:"none",opacity:b.o.opacity/100,height:b.o.modal?f[0]:0,width:b.o.modal?f[1]:0,position:"fixed",left:0,top:0,zIndex:b.o.zIndex+1})).appendTo(b.o.appendTo);b.d.container=d("<div></div>").attr("id",b.o.containerId).addClass("btnt-container").css(d.extend(b.o.containerCss,{display:"none",position:"fixed",zIndex:b.o.zIndex+2})).append(b.o.close&&b.o.closeHTML?d(b.o.closeHTML).addClass(b.o.closeClass):
"").appendTo(b.o.appendTo);b.d.wrap=d("<div></div>").attr("tabIndex",-1).addClass("btnt-wrap").css({height:"100%",outline:0,width:"100%"}).appendTo(b.d.container);b.d.data=a.attr("id",a.attr("id")||b.o.dataId).addClass("btnt-data").css(d.extend(b.o.dataCss,{display:"none"})).appendTo("body");b.setContainerDimensions();b.d.data.appendTo(b.d.wrap);if(k||l)b.fixIE()},bindEvents:function(){var a=this;d("."+a.o.closeClass).bind("click.btnt",function(b){b.preventDefault();a.close()});
a.o.modal&&a.o.close&&a.o.overlayClose&&a.d.overlay.bind("click.btnt",function(b){b.preventDefault();a.close()});d(document).bind("keydown.btnt",function(b){if(a.o.modal&&b.keyCode===9)a.watchTab(b);else if(a.o.close&&a.o.escClose&&b.keyCode===27){b.preventDefault();a.close()}});d(window).bind("resize.btnt",function(){f=a.getDimensions();a.o.autoResize?a.setContainerDimensions():a.o.autoPosition&&a.setPosition();if(k||l)a.fixIE();else if(a.o.modal){a.d.iframe&&a.d.iframe.css({height:f[0],
width:f[1]});a.d.overlay.css({height:f[0],width:f[1]})}})},unbindEvents:function(){d("."+this.o.closeClass).unbind("click.btnt");d(document).unbind("keydown.btnt");d(window).unbind("resize.btnt");this.d.overlay.unbind("click.btnt")},fixIE:function(){var a=this,b=a.o.position;d.each([a.d.iframe||null,!a.o.modal?null:a.d.overlay,a.d.container],function(c,h){if(h){var g=h[0].style;g.position="absolute";if(c<2){g.removeExpression("height");g.removeExpression("width");g.setExpression("height",
'document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight + "px"');g.setExpression("width",'document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth : document.body.clientWidth + "px"')}else{var e;if(b&&b.constructor===Array){c=b[0]?typeof b[0]==="number"?b[0].toString():b[0].replace(/px/,""):h.css("top").replace(/px/,"");c=c.indexOf("%")===-1?c+' + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"':
parseInt(c.replace(/%/,""))+' * ((document.documentElement.clientHeight || document.body.clientHeight) / 100) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"';if(b[1]){e=typeof b[1]==="number"?b[1].toString():b[1].replace(/px/,"");e=e.indexOf("%")===-1?e+' + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"':parseInt(e.replace(/%/,""))+' * ((document.documentElement.clientWidth || document.body.clientWidth) / 100) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'}}else{c=
'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"';e='(document.documentElement.clientWidth || document.body.clientWidth) / 2 - (this.offsetWidth / 2) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'}g.removeExpression("top");g.removeExpression("left");g.setExpression("top",
c);g.setExpression("left",e)}}})},focus:function(a){var b=this;a=a&&d.inArray(a,["first","last"])!==-1?a:"first";var c=d(":input:enabled:visible:"+a,b.d.wrap);setTimeout(function(){c.length>0?c.focus():b.d.wrap.focus()},10)},getDimensions:function(){var a=d(window);return[d.browser.opera&&d.browser.version>"9.5"&&d.fn.jquery<"1.3"||d.browser.opera&&d.browser.version<"9.5"&&d.fn.jquery>"1.2.6"?a[0].innerHeight:a.height(),a.width()]},getVal:function(a,b){return a?typeof a==="number"?a:a==="auto"?0:
a.indexOf("%")>0?parseInt(a.replace(/%/,""))/100*(b==="h"?f[0]:f[1]):parseInt(a.replace(/px/,"")):null},update:function(a,b){var c=this;if(!c.d.data)return false;c.d.origHeight=c.getVal(a,"h");c.d.origWidth=c.getVal(b,"w");c.d.data.hide();a&&c.d.container.css("height",a);b&&c.d.container.css("width",b);c.setContainerDimensions();c.d.data.show();c.o.focus&&c.focus();c.unbindEvents();c.bindEvents()},setContainerDimensions:function(){var a=this,b=k||m,c=a.d.origHeight?a.d.origHeight:d.browser.opera?
a.d.container.height():a.getVal(b?a.d.container[0].currentStyle.height:a.d.container.css("height"),"h");b=a.d.origWidth?a.d.origWidth:d.browser.opera?a.d.container.width():a.getVal(b?a.d.container[0].currentStyle.width:a.d.container.css("width"),"w");var h=a.d.data.outerHeight(true),g=a.d.data.outerWidth(true);a.d.origHeight=a.d.origHeight||c;a.d.origWidth=a.d.origWidth||b;var e=a.o.maxHeight?a.getVal(a.o.maxHeight,"h"):null,i=a.o.maxWidth?a.getVal(a.o.maxWidth,"w"):null;e=e&&e<f[0]?e:f[0];i=i&&i<
f[1]?i:f[1];var j=a.o.minHeight?a.getVal(a.o.minHeight,"h"):"auto";c=c?a.o.autoResize&&c>e?e:c<j?j:c:h?h>e?e:a.o.minHeight&&j!=="auto"&&h<j?j:h:j;e=a.o.minWidth?a.getVal(a.o.minWidth,"w"):"auto";b=b?a.o.autoResize&&b>i?i:b<e?e:b:g?g>i?i:a.o.minWidth&&e!=="auto"&&g<e?e:g:e;a.d.container.css({height:c,width:b});a.d.wrap.css({overflow:h>c||g>b?"auto":"visible"});a.o.autoPosition&&a.setPosition()},setPosition:function(){var a=this,b,c;b=f[0]/2-a.d.container.outerHeight(true)/2;c=f[1]/2-a.d.container.outerWidth(true)/
2;if(a.o.position&&Object.prototype.toString.call(a.o.position)==="[object Array]"){b=a.o.position[0]||b;c=a.o.position[1]||c}else{b=b;c=c}a.d.container.css({left:c,top:b})},watchTab:function(a){var b=this;if(d(a.target).parents(".btnt-container").length>0){b.inputs=d(":input:enabled:visible:first, :input:enabled:visible:last",b.d.data[0]);if(!a.shiftKey&&a.target===b.inputs[b.inputs.length-1]||a.shiftKey&&a.target===b.inputs[0]||b.inputs.length===0){a.preventDefault();b.focus(a.shiftKey?"last":
"first")}}else{a.preventDefault();b.focus()}},open:function(){var a=this;a.d.iframe&&a.d.iframe.show();if(d.isFunction(a.o.onOpen))a.o.onOpen.apply(a,[a.d]);else{a.d.overlay.show();a.d.container.show();a.d.data.show()}a.o.focus&&a.focus();a.bindEvents()},close:function(){var a=this;if(!a.d.data)return false;a.unbindEvents();if(d.isFunction(a.o.onClose)&&!a.occb){a.occb=true;a.o.onClose.apply(a,[a.d])}else{if(a.d.placeholder){var b=d("#btnt-placeholder");if(a.o.persist)b.replaceWith(a.d.data.removeClass("btnt-data").css("display",
a.display));else{a.d.data.hide().remove();b.replaceWith(a.d.orig)}}else a.d.data.hide().remove();a.d.container.hide().remove();a.d.overlay.hide();a.d.iframe&&a.d.iframe.hide().remove();setTimeout(function(){a.d.overlay.remove();a.d={}},10)}}}})(jQuery);
</script>
<script type="text/javascript">
    /**  * jQuery.browser.mobile (http://detectmobilebrowser.com/)  * jQuery.browser.mobile will be true if the browser is a mobile device  **/ (function(a){jQuery.browser.mobile=/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))})(navigator.userAgent||navigator.vendor||window.opera);
  if(jQuery.browser.mobile)
    {
       //console.log('You are using a mobile device!');       
    }
    else
    {
        jQuery(function($) {
            // Load dialog on page load
            $('#subscribe-widget').modal();
            // Load dialog on click
            $('#subscribe-button .subscribe').click(function(e) {
                $('#subscribe-widget').modal();
                return false;
            });
        });
       //console.log('You are not using a mobile device!');
    }  
    
</script>

 

After this, include subscription.php file in footer.php file. Use following code.


<?php require ("subscription.php");?>
<?php wp_footer(); ?>

 

After this you will your subscription popup like this.

add feedburner email subscription popup wordpress without plugin
add feedburner email subscription popup wordpress without plugin

You can see demo on following URL:

Feedburner form popup DEMO

Without writing too much, we given code. If you want to download script and images which are used in script, than use following URL.
[viral-lock message=”Download Link is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

Feedburner form popup-assets

[/viral-lock]

 

Note: In script, we used images from url and change the our feedburner name to your site.

how to check broken links in wordpress website

Broken links are harmful for wordpress website SEO. In wordpress tutorial, will show you, how to check broken links in wordpress. How to fix broken links. Broken links are bad and annoying, Broken links will give the bad impression to user about your wordpress website.

Why Broken links are not good for SEO.

Hare are Google listed Webmaster Guidelines, you can clearly see that broken links are mentioned in guidelines. Google is mentioned about broken links. Check “Design and content guidelines” section. Google clearly says following point.
  • Check for broken links and correct HTML.

If Google is giving guidelines about broken links than, it is so important we should check broken links in wordpress and fix or remove broken links from wordpress site. Google actually penalized webpages which has broken links and it affect your search engine page rank.

How Broken links will be generated on wordpress website?

Main reason behind broken links which we found is, comments. Many commenter use fake domain names and URLs which does not exists. So while approving comment, check URL which posted by user. Another reason is wordpress themes. Many people change their wordpress themes. Some times, when theme has different custom image sizes are used in theme, Images are not found which are specified in theme. So whenever you change your wordpress theme, check images are not broken.

Some time you use reference URLs in wordpress site. If webmaster shut down their sites than reference URL will be broken. So you need to check broken URLs on regular basis.

We recommend to check broken URLs at least in one month.

how to check broken links in wordpress website

We found useful wordpress plugin for checking and fixing broken links. You need to install following wordpress plugin.

Broken Link Checker

This plugin will check your posts, comments and other content for broken links and missing images, and notify you if any are found. This plugin will monitor your blog looking for broken links and let you know if any are found.

Features

  • Monitors links in your posts, pages, comments, the blogroll, and custom fields (optional).
  • Detects links that don’t work, missing images and redirects.
  • Notifies you either via the Dashboard or by email.
  • Makes broken links display differently in posts (optional).
  • Prevents search engines from following broken links (optional).
  • You can search and filter links by URL, anchor text and so on.
  • Links can be edited directly from the plugin’s page, without manually updating each post.
  • Highly configurable.

How to Use Broken link checker plugin

After activating the plugin, go to Tools » Link Checker. plugin will  work in background and find out the website has broken links. If you have the large amount of posts than it will take some time depending on your server capability.

If your site has no broken links than you will see following screenshot.

How to Use Broken link checker plugin
How to Use Broken link checker plugin

If you site has broken links then you will see following result. In this screen shot we shown you how to fix broken links. There are some options can be found for each list item. Following are options.

  • Edit link
  • Unlink
  • Not Broken
  • Dismiss
how to check broken links in wordpress
how to check broken links in wordpress

You can choose option which you want. From list page you can edit URL and fix link. If URL not exist than you can unlink URL.

After you are fixing of all broken links. You can disable this wordpress plugin and After one month you can again process same thing. This will increase your website page ranking and users will not get bad impression about your wordpress website.

how to limit number of wordpress posts in rss feed

As per wordpress pages, we can limit number of wordpress posts in rss feed. Through RSS feed (feedburner and other feeds) we can subscribe to any website. RSS feed need to managed properly and shown to user. Some client and webmaster want to show limited nuber of post to user in RSS feed view, It is encourage-able to visitors to view your site.

how to limit number of wordpress posts in rss feed

What you need is, First login to worpdress admin panel. Than go to Settings » Reading page in your WordPress admin dashboard menu (left side).

WordPress itself given you facility to control RSS feed post numbers through wordpress admin panel itself.

[viral-lock message=”Setting image is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

limit number of wordpress posts in rss feed
how to limit number of wordpress posts in rss feed

[/viral-lock]

After this, Find ‘Syndication feeds show the most recent’  textbox option and change the value(number) which you want to be shown to user in RSS feed page.

You will find “For each article in a feed, show ” radio box there, Choose option what you want to show to user in RSS feed. We suggest you to use “Summary” because it will be good for SEO purpose. Than Just save the changes.

Than go to your RSS feed page. If you dont know RSS feed page than use following link. Do not forget to change the your domain name.

https://yourdomain.com/feed

Your RSS feed will look as follows:

how to limit number of wordpress posts in rss feed

Tutorial is done, Now you have successfully limited number of wordpress posts in rss feed for your wordpress website. You will like above tutorial which will tell you Add Feedburner RSS feed email subscription form in wordpress without plugin and If you want to show thumbnail in RSS feed then check above tutorial Show Post Thumbnail or Featured image in WordPress RSS Feed

Many Hacks Related to wordpress and RSS feed: WordPress and RSS feed Hacks

how to install varnish with wordpress and apache

There are many caching solution available in open source. But Varnish is best in among. In this article, We given full steps to use and install varnish with wordpress and apache server . varnish setup with your wordpress site. Many website webmasters installed Varnish on their production servers to handle millions of requests without delay in response. There are many caching plugin like W3 Total Cache, WP Super Cache, Hyper Cache and so many..

Varnish is open source software

Varnish is free open source software licensed under a two-clause BSD licence aimed to really super boost server performance. In short, it will work as web accelerator between any server that speaks with HTTP (Apache or any other).

how to install varnish with wordpress and apache
how to install varnish with wordpress and apache

Why Apache or Nginx is Enough to Handle Huge Traffic
Many system administrator do many tricks with Apache because it performs really bad when the server is getting very high requests. Some people started using other servers like Ngnix and LiteSpeed. WordPress itself are using Ngnix server for many years for production environment. But still performance and response time of website is not that much fast with these plugins. So Best solution is Varnich Cache.

Varnish Explained Here

Vanish server started working on top of Apache server. When HTTP request comes to server first it will go the varnish server, If Vanish server has the response in memory cache then it will give response immediately, If Varnish server does not has cache for that request then it will go to apache server and get the response and keep in cache. Next request will delivered by Varinish cache, which will be so fast. Using varnish cache you can increase your server performance and response time by 300 to 900x. I personally checked response time difference. Before installing varnish cache my server response time was 3.46 second. After installing Varnish Cache, my server response time was 0.3, Means My server response increased by 1000x.

In following diagram, we explained, how varnish server process request.

varnish processing request compressed, how to install varnish with wordpress and apache
varnish processing request compressed, how to install varnish with wordpress and apache

Why install varnish with wordpress

  1. It will reduce server load , by reducing CPU work
  2. It will load your load your WordPress website very fast, because vanish cache stored in RAM.
  3. Your wordpress site SEO will increase, Because your site will load so fast
  4. Response time will reduce by 1000x
  5. Google page speed response score improves by at-least 20%

how to install varnish with wordpress and apache

Note: You can use this tutorial for setup varnish with any apache website. If you used HTML, ROR, JAVA, PHP for your website than you can set up varinish as we shown in this article. Here, we are assuming you already installed wordpress with apache server on linux server.

We are using dedicated Linux (centos) server for hosting our sites. So here we given steps can be applicable for Red Hat, Centos, Fedora, ubuntu server. But for ubuntu server you need use “apt-get install” instead of yum install.

So now Just follow my steps to install the varnish server. For latest version of Linux, you don’t need to install repository. But for older linux version you need to install the Varnish server repository. For that use following command to install varnish repository.

rpm -Uvh http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release/varnish-release-3.0-1.noarch.rpm

Than you will be ready for install varnish server. Use following command for installing varnish server. You need to run following command as root. So first became root.

yum install varnish

Configure Varnish to work on port 80

usually Apache run on port 80 and your all sites will run on port 80. So as I told you earlier in this article. (check Varnish Explained section) Varnish work on top of apache server So you need to set up varnish on port 80. In CentOS, RedHat, Fedora, and Ubuntu server, Varnish configuration file located in “/etc/sysconfig/varnish”. You can edit file using vim or vi editor or you can download file to your PC and edit it then upload to server.

I am using vim here.


vim /etc/sysconfig/varnish

Please change files first part code as per I shown in image. OR you can download setting file from here:

[viral-lock message=”Download Link is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

https://github.com/purab/varnish/blob/master/varnish
 

[/viral-lock]

  • Change Default Varnish Config file

Got to “Alternative 2” section and change setting as I shown in image. Un-comment all the lines after “Alternative 2” as I shown.

By default -s setting will be pointed to filesystem, change that to memory. This is important, because we want, varnish give response from memory.

you need to change “-a : 6081 \” to “-a : 80 \” as we shown here in image. You can change “256m” to higher number, which is depends on your server configuration. If you have higher memory server then you can 512mb or 1GB for Varnish server. Many websites are using 4gb for varinsh servers. But they have a huge amount of traffic.

varnish configuration, install varnish with wordpress and apache
varnish configuration, install varnish with wordpress and apache

 Second Part of configuration – go to end of file, using “shit+g” key. Change configuration as per I shown.

Got to “Alternative 3” section and change setting as I shown in image. Comment all the lines after “Alternative 3”

varnish default config , install varnish with wordpress and apache
varnish default config , install varnish with wordpress and apache
  •  Change server config of Varnish

Like Apache server, Varnish server VCL file found in “/etc/varnish/default.vcl” location. Varnish VCL file is configuration for looking for apache(server) response data(content). You can edit this file using vim editor as per shown in following image OR you can download file from following location.

[viral-lock message=”Download Link is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

https://github.com/purab/varnish/blob/master/default.vcl
 

[/viral-lock]

 

varnish server config, install varnish with wordpress and apache
varnish server config, install varnish with wordpress and apache

Change the port 80 to 8080 port as We shown in image. Means Varnish server will generate cache from port 8080 so you need configure your apache server on port 8080.


backend default {
.host = "127.0.0.1";
.port = "8080";
}

Now Varnish configuration is complete. Now we need to configure apache server to send apache in back of varnish server.

You need to change following setting of your apache server. By default apache config file is htttpd.conf or apache.conf file. You will find this file in “/etc/httpd/conf/httpd.conf” location. For ubuntu that will be other location. Open your apache config file.

You can download apache configuration file from here. You can refer only “custom.conf” file. it has all changed configuration.

https://github.com/purab/varnish/blob/master/custom.conf
https://github.com/purab/varnish/blob/master/httpd.conf

We created custom.conf file and added under “/etc/httpd/conf.d/” folder. So that file will be automatically loaded in apache config.

You can add following code in your apache configuration file as we shown in following image. You need to change the NameVirtualHost 80 to 8080. So your apache server will run on port 8080.

apache server config with varnish,  install varnish with wordpress and apache
apache server config with varnish, install varnish with wordpress and apache

You need to change VirtualHost entries for each of your domain. This is very important, If you do not change this properly then your apache server will through error while restarting.


NameVirtualHost *:8080

#Browser cache code
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.[0678] no-gzip
BrowserMatch \bMSIE\s7 !no-gzip !gzip-only-text/html
BrowserMatch \bOpera !no-gzip
Header append Vary User-Agent

#purabtech.in
<VirtualHost *:8080>
ServerAdmin purabdk@gmail.com
DocumentRoot /home/siwan/purabtech.in
ServerName purabtech.in
ServerAlias www.purabtech.in
ErrorLog logs/wordpressapi-error_log
CustomLog logs/wordpressapi-access_log common
</VirtualHost>

 

  •  Now your Varnish and Apache configuration are done. So time to restart both servers.

First Stop the Apache server and start the Varnish server. After starting Varnish server. Again start the apache server. You can use following commands step by step. Use commands in following order.


service httpd stop

service varnish start

service httpd start

Note: If you try to start varnish server without stopping apache server then it will never start because it will try to start using port 80.

  • Test Website performance and response time

How can you test your site pages speed and response time. Go to following “Google pagespeed” URL to test the website response time.

PageSpeed Insights 

Check Varnish service is running for your site. go to following URL and add your website URL in inputbox and select “service scan” checkbox and click on go button.

http://centralops.net/co/domaindossier.aspx

You will get response as shown in following image.

varnish-detection-response

As per explained in this article. After varnish configuration, your website will perform much faster then earlier and server CPU will not be consumed by apache server. We are using small dedicated server so we used only 256mb memory. If you have 1gb RAM of our server then use 256mb means one-fourth of memory for varnish server. When you have all code and database of same server.

Varnish Useful commands

# varnishlog : Provides detailed information on requests.
# varnishtop : It reads varnishd shared memory logs and presents a most commonly occurring log entries.
# varnishadm : Command-line varnish administration used to reload vcl and purge urls.
# varnishstat : Provides all the info you need to spot cache misses and errors.
# varnishhist : Provides a histogram view of cache hits/misses.

By “varnishstat” command you can check real-time statistics of varnish server. You can see following items

  • Client connection
  • Hit rate ration
  • Hit rate average
  • Number of client connections accepted

Following is screenshot of my production site. There are a lot of useful data provided by varnish stats

varnish varnishstat, install varnish with wordpress and apache
varnish varnishstat, install varnish with wordpress and apache

 

Create Varnish Log File

Using following command you can create varnish request log file as per apache log file. In this file you will get similar information like apache access log.


varnishncsa -c -a -d -w /var/log/varnish/varnish.log

For more varnish commands you can go to varnish site using following URL.

https://www.varnish-software.com/static/book/Getting_started.html#the-management-interface

Now you are set with varnish server and wordpress site. Above article can be used for any linux distribution like, Fedora, Ubuntu, Centos, RedHat and Suse. Commands will be same and configuration will be same.

In wordpress configuration you do not need to change anything. With Varnish server .htaccess file will not break because still main webserver is  apache.

If you still need assistance to install Varnish server and configure production server then contact to me.

how to add google analytics to wordpress footer

Google analytics became primary requirement of every websites. Google analytics provides every aspect of data with all type of user behavior and information. Where from user came to your site. How much time user spends on user website. which pages are most popular in your website.

Similarly wordpress is widely used for creating websites. So here in this article I will show you how to add google analytics in wordpress footer.

how to add google analytics to wordpress footer

Need google analytics account

First you need the google analytics account, If you don’t have than,  Go to the Google Analytics site and create a new account. There are many sites or check for YouTube video for getting the google analytics code from site.

Add Google Analytics script to Your WordPress Theme

Login to wordpress admin panel, Then goto “Appearance->editor” section. Then open footer.php file in editor. Before “” close tag put your google analytices code there. After adding analytics code save the file.

how to add google analytics to wordpress footer
how to add google analytics to wordpress footer

This is easiest step to add the google analytics to your wordpress theme.

There are many plugins which will give you facility to add google analytics to your wordpress site. Here we recommend you to use following wordpress plugin for adding the google analytics.

WP Google Analytics (https://wordpress.org/plugins/wp-google-analytics/)

how to add google analytics to wordpress footer
how to add google analytics to wordpress footer

WP Google Analytics makes it easy to track your site’s usage, with lots of helpful additional data.

Features:

  • Uses Google’s asynchronous tracking method which is faster and more reliable.
  • Automatically tracks site speed
  • Option to log outgoing links as events
  • Option to log 404 errors as events
  • Use custom variables in Google Analytics to track additional data on page views including:
    • Author
    • Categories
    • Tags
    • Context (such as home, category, post, author, etc)
    • Date
    • Logged in
    • Anything – Use the built-in filter to add your own!
  • Allows you to ignore any user roles (administrators, editors, authors, etc)

WordPress Theme Development: The Pre-Coding Homework You Ought to do

The razmataz of the WordPress realm continues to beam and grow at an unprecedented rate as more and more webmasters lean towards it, choosing to host their blog on a CMS platform that gives them the maximum room to innovate and ideate. WordPress fits the fill, ever so obligingly.

Pre-Coding Homework You what to do

Pre-Coding Homework You what to do
Pre-Coding Homework You what to do

Now, there are folks who would rather develop their own WordPress theme rather than going in with the deluge of free and paid themes that are available on on the web. And they do draw a lot of confidence from their exceptional coding abilities. Besides, they want their own name up there on WordPress.org as a theme contributor. But, is a darn too coding procedure all that there is to developing an impressive WordPress theme? Arguably not.

There are hordes of things for you to consider before you begin writing the codes, and this is what this article aims to introduce you with:

To Begin With

With increasing number of developments making their way into the WordPress ambit, creating your own WordPress theme is becoming easier by the day. The standard way of starting to building a theme is having an index.php and style.css file and you are good to go.

That said, is that all you need when the agenda is to stand out from the herd? Not really. What you need is to branch out to the seemingly uncharted territories and strive to innovate. And this is where you would need a comprehensive knowledge of HTML and CSS so that you can dig in your heels deeper and get down to the fibre of theme development. Having hands-on expertise in HTML5 and CSS3 is what would make difference at the end of the day. Working on WordPress becomes an exercise with much-greater benefits once you know your way around these two tools.

Furthermore, you need to be clear-eyed about the fact that your theme should create no compatibility hassles with the latest versions of WordPress (upgrading to which is critically important at all times). Besides, the plugins you wish to install should work in perfect unison with your theme.

Chart Out Your Tasks Well in Advance

As iterated earlier, theme development goes beyond coding. And there are a bunch of considerations to keep in mind. You should have time as luxury for:

  • Constantly upgrading the theme and applying patches to it
  • Be responsive to the customer issues
  • Ensure theme maintainability at all times

What would rather serve you the best is a detailed study of the WordPress documentation.

Look at Few Themes for the Influence and Know Your Files

There are some exceptionally impressive and inspiration WordPress themes out there to learn from. I won’t mention any specific as it would rather serve you better if you do a fair bit of research and get a diversified idea.

Now, there are files that form the very fibre of any WordPress website. Get to know them:

  • index.php
  • single.php
  • page.php
  • style.css
  • functions.php
  • search.php
  • header.php
  • sidebar.php
  • footer.php
  • archive.php
  • comments.php
  • 404.php

Evidently, any Wordpres theme consists of a diverse range of PHP template files and you have to get them in order for every element of your theme to work appropriately.

Coming back to the documentation and the WordPress submission guidelines, make sure you don’t skimp over the basic ones.

The APIs Will Help You Sail Through

The basic process of writing a WordPress theme has to be accompanied with knowing the APIs inside out. The APIs cover several aspects of theme development and having a clear-eyed idea of how they would assist you in deliverables like theme customization, widgets, shortcodes, among others, will go a long way in streamlining your exercise.

.andthathastobefollowedby

You would need to be sure about elements like licensing and the architecure. Now you can use any of the several services that provide you with necessary tools to create themes without worrying about APIs, compatibility, licensing, etc. that is, if you are willing to spend a bomb. Note: avoid using the theme generators, as they are more often than not rejected by WordPress.org

Let your theme development endeavor have a sense of order and half the ground is covered. For the rest of it, your coding talent should suffice.

 

how to remove unwanted image sizes from wordpress theme

Many times you do not need the many image sizes for wordpress. You need the original image only for your wordpress sites. Sometime you need the original and thumbanil image only. But many wordpress themes creates the multiple image version in your site which is not useful. Using following code you can remove the unwanted images while uploading the images.

Here in this article I going to show you, how we can remove unwanted image sizes from wordpress theme. Using code snippet, you can easily remove unwanted image sizes.

remove unwanted image sizes

You just need to add following code into functions.php file.

function wpapi_remove_image_size($sizes) {
                unset( $sizes['small'] );
                unset( $sizes['medium'] );
                unset( $sizes['large'] );
                return $sizes;
        }
add_filter('image_size_names_choose', 'wpapi_remove_image_size');
remove unwanted image sizes
remove unwanted image sizes

How to use the cron job with WordPress

In linux OS and windows OS cron jobs been used for backgroud tasks, many times you need to execute the some background tasks based on time. In wordpress creating the cron jobs is very easy. For creating the cronjob you can use the wp_schedule_event() event. You can run the cron based on time defined.

In linux and mac box adding cronjobs are different then using in wordpress. WordPress itself supports the adding cronjobs events or tasks. Here in this article I explained about using cron job with WordPress.

CRON job with WordPress

You can pass following parameters:
hourly
twicedaily
daily

<?php
add_action('wpapi_hourly_event', 'do_this_daily');

function wpapi_activation() {
    if ( !wp_next_scheduled( 'wpapi_hourly_event' ) ) {
        wp_schedule_event(time(), 'daily', 'wpapi_daily_event');
    }
}
add_action('wp', 'wpapi_activation');

function do_this_hourly() {
    // do something daily
}
?>
cron job with WordPress
cron job with WordPress

For more detailed information you can visit
http://codex.wordpress.org/Function_Reference/wp_schedule_event