how to disable wordpress post revisions

disable wordpress post revisions and increase wordpress performance. For improving the WordPress website or blog performance you need use following method.

WordPress saves the post revisions after every 2 min. That takes so much mysql storage.
To save MySQL storage, some WordPress user will be happy using this method, this method is Disable WordPress Post Revision.

how to disable wordpress post revisions

Why we need disabled this featured?

It’ because WordPress created such as dummy data revision and this one make our table sized increased. And if you have limited space, this is bad idea, and of course disable Post Revision also made your WordPress running faster.

Open your wp-config.php file and put the following code in that file. If you are not wordpress developer then dont use following code. Please consult with any wordpress developer for this code.

/* disable post-revisioning nonsense */
define('WP_POST_REVISIONS', FALSE);

Modify wordpress Custom excerpt length

In wordpress api we having the the_excerpt method for showing the short description from wordpress post.
On WordPress 2.9 there are new featured that we can added on the_excerpt(), one of them is change the excerpt length.

Modify wordpress Custom excerpt length

For Modify wordpress Custom excerpt length we need use the filter for modify the wordpress excerpt length. Use our custom code and put in functions.php file

For changing the length of excerpt we need use the filter for modify the wordpress excerpt length.
We only needed to put some function on our functions.php themes file and added some hook to call this functions.

<?php
// Add custom excerpt length
function custom_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'custom_excerpt_length');
?>

Using above code you can control the character length in wordpress description.

how to show author information on each wordpress post

show author information on each wordpress post is really good habit in wordpress post. So reader will know information writer who is writing the article. Many people like this information and they really read the information about author.

how to show author information on each wordpress post

how to show author information on each wordpress post
how to show author information on each wordpress post

For showing the author information you need put following code in the functions.php file show after your post content the author information will displayed to reader.


function get_author_bio($content=''){
global $post;

$post_author_name=get_the_author_meta("display_name");
$post_author_description=get_the_author_meta("description");
$html="</pre>
<div id="about_author" class="clearfix">\n";
$html.="<img class="avatar" src="http://www.gravatar.com/avatar.php?gravatar_id=&quot;.md5(get_the_author_email()). &quot;&default=&quot;.urlencode($GLOBALS[" alt="PG" width="80" height="80" />\n";
$html.="
<div class="author_text">\n";
$html.="
<h4>Author: ".$post_author_name."</h4>
\n";
$html.= $post_author_description."\n";
$html.="</div>
</div>
<pre>
\n";
$html.="</pre>
<div class="clear"></div>
<pre>
\n";
$content .= $html;

return $content;
}

add_filter('the_content', 'get_author_bio');

Just put the above code in functions.php file. You dont need to do code in single.php file.

Prevent external requests for your WordPress blog

When you run the wordpress blog there must be many external links would be created by others. which are not good for your blog. Some sites may be only using your wordpress images by your images links.

Prevent external requests for your WordPress

For Prevent external requests for your WordPress blog you need to use simple trick. WordPress api is given this facility to prevent the external request.

To do so, open your wp-config.php file and copy paste the following code:

define('WP_HTTP_BLOCK_EXTERNAL', true);

It will block external requests from that time on. Though, some plugins need the external request to work properly. If you experience problems, you can define a whitelist by pasting the code below into wp-config.php. Don’t forget to replace my url by the one needed by the plugin.

define('WP_ACCESSIBLE_HOSTS', 'purabtech.in');

if you are still having any issue then please contact to me.

show pdf in wordpress blog or website

Many people want to show there pdf files in wordpress blog. PDF is really popular format for showing the document with graphics and text and design and graphs. Without loosing the quality of text and graphics if we need to show the content then PDF is really nice format.

pdf in wordpress

pdf in wordpress
pdf in wordpress

In business world for presentation purpose all people mostly use the PDF document. Some wp developers asked about showing the pdf in wordpress.

For without any issue if you want to show the PDF document then you need to just open functions.php file and put following code in that file.
Following code I written for creating the shortcode in wordpress

function pdflink($attr, $content) {
return '<a href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>';
}
add_shortcode('pdf', 'pdflink');

For showing link of PDF file in article or post you need add the following lines in the article.

[pdf href=”http://yoursite.com/linktoyour/file.pdf”]View PDF[/pdf]

Note: Upload the PDF file to your wordpress and then get the path of PDF file and then put above lines in article.
Change the path as you required.
Above code will create pdf link for your pdf document in your site.

If you does not want to create PDF link in your site and you want to show the pdf doc in your site then use following code.

function pdfshow($attr, $content) {
return '<iframe src="http://docs.google.com/gview?url='.$attr['href'] .'&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>';
}
add_shortcode('pdfshow', 'pdfshow');

For showing the PDF file in article or post you need add the following lines in the article.

[pdfshow href=”http://yoursite.com/linktoyour/file.pdf”]View PDF[/pdf]

We are looking for pdf in wordpress post, wordpress pdf tutorial,  wordpress tutorial, wordpress documentation pdf, wordpress ebook pdf, wordpress book, wordpress ppt, wordpress tutorial for beginners this for wordpress. Here we can add the pdf support using my code in your wordpress sites.

how to display rss readers on your wordpress

you can display rss readers on your wordpress using following code. Many wordpress blogger want to show the information RSS  readers of their site.  We given code here in this article.

how to display rss readers on your wordpress

Showing the RSS feed information to your user is good for seo and smo.

Just following code in your functions.php file.


function get_rss_readers($feed_id,$interval = 7){
$today_date = date('Y-m-d', strtotime("now"));
$ago = date('Y-m-d', strtotime("-".$interval." days"));
$feed_url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=".$feed_id."&dates=".$ago.",".$today_date;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $feed_url);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];

$rss_readers = 0;
foreach($xml->feed->children() as $circ){
$rss_readers += $circ['circulation'];
}

return round($rss_readers/$interval);
}

In sidebar.php or where you want to show your rss feed reader count there you should use the following code.

$rss_readers = get_rss_readers('wordpressapi');
echo "We currently have ".$rss_readers." RSS readers";

wordpress add featured image to rss feed

In Many RSS feed we always see the images are showing. We can put the featured image in wordpress rss feed. WP RSS feeds are very important for SEO purpose. If you show the featured image on RSS feed then that will be great.

wordpress add featured image to rss feed

You need to open the functions.php file and put following code in that file. Then if you check your rss feed then RSS feed will be showing the featured images in RSS feed.

function thumbnail_in_rssfeed($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<div style="float:left;">' . get_the_post_thumbnail($post->ID) . '</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'thumbnail_in_rssfeed');
add_filter('the_content_feed', 'thumbnail_in_rssfeed');

This code will show the featured images in content and excerpt RSS feed.

how to add custom thumbnail size to wordpress

From wordpres 2.9 version we got the featured image option in wordpress.  We have given code to add custom thumbnail size to wordpress themes.  Means you can relate the image to wordpress post without showing in post.

how to add custom thumbnail size to wordpress

If you are using the wordpress 2.9.2 or greater version then this feature is available in your wordpress but you need to enable this feature in your worpdress by using following function.

open your functions.php file and put following code in that file for enable the featured post feature in your wordpress

add_theme_support( 'post-thumbnails' );

By default, WordPress gives you some image sizes when you upload an image. These image sizes are:

* Thumbnail
* Medium
* Large
* Full (the image you uploaded)

For showing the the featured image in your post you can use the following code

if ( has_post_thumbnail() )

the_post_thumbnail( 'thumbnail' );  // for showing the thubnail.
the_post_thumbnail( 'medium' ); // for showing the medinum size thubnail image
the_post_thumbnail( 'full' );  // for showing the full size thubnail image

If you want to only show the specific image size in featured thubnail then use the following code.

add_filter( 'post_thumbnail_size', 'my_post_image_size' );

function my_post_image_size( $size ) {
$size = 'medium';
return $size;
}

 

For fixing the old images issue with featured images.
You can use the following article.
https://purabtech.in/media-library-not-displaying-images-after-importing-posts/

Add Custom Content to End of RSS feed for wordpress

wordpress tutorial for, Add Custom Content to End of RSS feed for wordpress. WordPress has own wordpress api to designed many RSS feed format. code given here.

Add Custom Content to End of RSS feed for wordpress

RSS (most commonly expanded as Really Simple Syndication) is a family of web feed formats used to publish frequently updated works—such as blog entries, news headlines, audio, and video—in a standardized format.

Add Custom Content to End of RSS feed for wordpress
RSS feed are very important. WordPress has own wordpress api to designed many RSS feed format.
In this tutorial I will show you how to add the custom text in your rss feed.
You just need to open your functions.php file and put following code in that file.

function feed_the_Filter($query) {
if ($query->is_feed) {
add_filter('the_content','add_to_feed');
}
return $query;
}
add_filter('pre_get_posts','feed_the_Filter');

function add_to_feed($content) {
$content .= '<p>Follow us on Twitter &amp;lt;a href="http://twitter.com/wordpressapi"&amp;gt;Wordpress API&amp;lt;/a&amp;gt;</p>';
$content .= '<p>Join our &amp;lt;a href="http://www.facebook.com/pages/wordpressapi/280021545846"&amp;gt;Wordpress API Facebook Community Page&amp;lt;/a&amp;gt;</p>';

return $content;
}

Set multiple excerpt length for custom post type wordpress

From wordpress 3.0 version wordpress intruded the custom post type function. Many wordpress theme developers are using custom post type method for showing different sections.

Set multiple excerpt length for custom post type wordpress

Many times we need to change the excerpt text length and showing on main landing page of custom post type.

Set multiple excerpt length for custom post type wordpress
Set multiple excerpt length for custom post type wordpress

You can set the different excerpt length for each custom post type. you just need to open functions.php file and put following code in file.


function new_excerpt_length($length) {
global $post;
if ($post->post_type == 'post')
return 32;
else if ($post->post_type == 'products')
return 65;
else if ($post->post_type == 'testimonial')
return 75;
else
return 80;
}
add_filter('excerpt_length', 'new_excerpt_length');

Using above code you can set the many excerpt lengths for your custom post type.

If you are still facing issue with custom post then please do write to me.