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.

how to add a favicon to your wordpress blog

We all know what is favicon logo. WordPress tutorial, how to add a favicon to your wordpress blog. In wordpress theme you can easily add the favicon logo using following code and put in functions.php file

how to add a favicon to your wordpress blog

you just need to open your functions.php file and put following code in that file.

function childtheme_favicon() { ?>
<link rel="shortcut icon" href="<?php echo bloginfo('stylesheet_directory') ?>/images/favicon.png" >
<?php }
add_action('wp_head', 'childtheme_favicon');
how to add a favicon to your wordpress blog
how to add a favicon to your wordpress blog

Note: your favicon.ico file need to placed under theme->images folder. then only this code will work

how to remove noindex nofollow from wordpress

There are many SEO wordpress plugin which insert the nofollow attribute in link. Using our code you can remove noindex nofollow from wordpress website. If you want to remove the nofollow attribute in link then just use the following code.

how to remove noindex nofollow from wordpress

Open your functions.php file from your wordpress theme folder and put following code in that file.


function remove_nofollow($string) {
$string = str_ireplace(' rel="nofollow"', '', $string);
return $string;
}
add_filter('the_content', 'remove_nofollow');

how to remove noindex nofollow from wordpress
how to remove noindex nofollow from wordpress

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.

Get Short Link from WordPress admin panel

WordPress tutorial, Get Short Link from WordPress admin panel. Many of them used bit.ly, tinyurl or is.gd sites. we used is.gd methods for shorten link.. Many people use the short link to post blog in twitter. Many of them use the bit.ly and tinyurl or is.gd websites. earlier I used the is.gd methods for shorten link.

Get Short Link from WordPress admin panel

From wordpress 3.0 wordpress introduced the shorten url functionality in wordpress. For enabling the shortlink in wordpress you need to open the functions.php from your theme folder and put the following code in that file.

the_shortlink($text = '', $title = '', $before = '', $after = '');

For more information about the the_shortlink method you should following URL
http://codex.wordpress.org/Function_Reference/the_shortlink

For showing the short link in your theme you need to use the following code in index.php or single.php or page.php file.

if ( function_exists('the_shortlink') ) the_shortlink( __('Shortlink'), __('Shortlink on this post'), ' ' );

This short url method is very useful for posting the URL in twitter or in any social networking site.

 

how to repair wordpress database automatically

WordPress has facility to automatically repair the wordpress database. If there is an issue with wordpress database with wordpress version.

how to repair wordpress database automatically

If you upgraded the wordpress then this feature is very helpful.

wordpress API provided a facility to repair the wordpress database automatically.
We just need to put following code in your worpdress configuration file.

Open your wp-config.php file and put following code in that file. After following line you can put the code.
define(‘DB_COLLATE’, ”);


define(‘WP_ALLOW_REPAIR’, TRUE);

This functionality is very important for new or old users of wordpress who have no knowledge about wordpress codebase. If you are having issue or problem with wordpress database then just put above line in wp-config.php file.
Using this setting wordpress will automatically repair the tables with new upgraded version of wordpress.

Automatically empty wordpress Trash comments and posts

WordPress tutorial, Automatically empty wordpress Trash comments and posts. Many times manually checking the deleted comments and posts is painful.  We need to keep our wordpress database clean so wordpress will perform faster.

Automatically empty wordpress Trash comments and posts

wordpress API provided to clean the commant and post trash automatically.
We just need to put following code in your worpdress configuration file.

Open your wp-config.php file and put following code in that file. After following line you can put the code.
define(‘DB_COLLATE’, ”);


define('EMPTY_TRASH_DAYS', 30 ); //assign the number of days

Be careful about assigning the days because after 30 days your trash will be deleted from database. So you cannot restore post or comments again from wordpress trash panel.

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/