How can we save Ram usages using some wordpress theme tricks

While running wordpress site, save Ram usage is always great idea and you can easily improve the site performance by simple wordpress theme tricks.

We mostly use the get_permalink(), get_the_title() methods in our wordpress theme. Do not pass the post ID as parameter.

if you’re doing a get_permalink or get_title() call with Post id, 8 out of 10 times you’ll need to more of that post than just the permalink, so this isn’t really a problem.

save Ram usage

Post object is actually already slightly faster than calling get_permalink with $post->ID (in get_post it then only sanitizes and adds to cache, it doesn’t fetch new data), but the real benefit comes when you add a variable called filter in the $post object, setting it to “sample”. Now you decide whether that post object is going to be cached or not and which variables it contains.

Pass the $Post object instead of Post ID.

Do not use the Custom fields. Your server need to fire extra custom quries on Mysql server.

If your are using $wpdb->get_results or new WP_Query( $args ) then add the order by.

How can we save Ram usages using some wordpress theme tricks
How can we save Ram usages using some wordpress theme tricks

If wordpress site is hacked then how to fix issue

Recently one of my wordpress site is hacked which is on wordpress. There is something wrong happening on server. We fixed issue with some steps, we given full steps for fixing issue. Due to disk I/O notification and CPU usages notification email I got to know.

If wordpress site is hacked then how to fix issue

There is something wrong happening on server.

First thing I did which is checking the apache access logs and error logs. I was getting per second 100 request from some IP addresses.

I stoped apache server and I took my database and filesystem backup. Deleted my admin username and added new administrator with new username.

You should use the Better WP Security wordpress plugin. This is very useful plugin.

iThemes Security (formerly Better WP Security)

I added following code in my .htaccess file

 # BLOCK BAD IPS
 <limit GET POST PUT>
 Order Allow,Deny
 Allow from all
 # uncomment/edit/repeat next line to block IPs
 # Deny from 123.456.789
 Deny from 192.111.152.122
 Deny from 192.111.144.233
 Deny from 110.85.90.123
 </limit>

If wordpress site is hacked then how to fix issue
If wordpress site is hacked then how to fix issue

But above code was still not helpful to me because disk I/O and apache process was taking time to sending the request to 403.

Then I blocked the IP Address on My Linux server using following commands.

 iptables -A INPUT -s 192.111.144.789 -j DROP
 iptables -A INPUT -s 192.111.152.122 -j DROP
 iptables -A INPUT -s 192.119.144.123 -j DROP

This solved my issue.

WordPress Under Huge Attack by Malicious Botnet: Protect your WP

From last two months WordPress Under Huge Attack by Malicious Botnet. Hackers are using thousands of individual computers and IP addresses. The botnet goes for the most obvious hack attempt: target sites with admin as the username , and will try to access that site’s password with a combination of thousands of possible passwords.

The WordPress site currently powers over 60 million websites and read by over a quarter of a billion users every month.When survey website W3Techs conducted a survey, it was found that 17% of the world’s websites are powered by WordPress.

While the attack may only succeed a small percentage of the time, the attack could result in hundreds or thousands of compromised servers when averaged over tens of thousands of sites powered by WordPress software.

If wordpress site is hacked then how to fix issue
If wordpress site is hacked then how to fix issue

I recommend following solutions for handling this issue
Change your WordPress admin Username

We can use the following article for changing the admin username
http://www.digitalkonline.com/blog/change-your-wordpress-admin-username/

Update wordpress version
WordPress founder Matt Mullenweg advises that if you do these first three “you’ll be ahead of 99% of sites out there and probably never have a problem.”

Use the Better WP Security plugin
As most WordPress attacks are a result of plugin vulnerabilities, weak passwords, and obsolete software. Better WP Security will hide the places those vulnerabilities live keeping an attacker from learning too much about your site and keeping them away from sensitive areas like login, admin, etc.Better WP Security takes the best WordPress security features and techniques and combines them in a single plugin thereby ensuring that as many security holes as possible are patched without having to worry about conflicting features or the possibility of missing anything on your site.

With one-click activation for most features as well as advanced features for experienced users Better WP Security can help protect any site.

iThemes Security (formerly Better WP Security)

wordpress get post meta custom post type: Smart way

WordPress tutorial for, wordpress get post meta custom post type smartly. The get_post_meta method is very useful in wordpress. here is simple code snippet.

wordpress get post meta custom post type

If you want to shorthand the get_post_meta call for the current post then you can use following:
you can use above method through functions.php file. You need to put following code in file:

function get_current_post_meta($key,$postID=null){
if(empty($postID)) {
global $post;
return get_post_meta($post->ID,$key,true);
} else {
return get_post_meta($postID,$key,true);
}
}

and you can call it like this:

echo get_current_post_meta('custom_tags');

Using above method you can pass the post id also.

wordpress get post meta custom post type: Smart way
wordpress get post meta custom post type: Smart way

wordpress 3.5 is Worst Update in release History

WordPress news, wordpress 3.5 is Worst Update in release History. we have high traffic site.  we updated our 3 of sites to 3.5 and sites goes down after wordpress update.

wordpress 3.5 is Worst Update in release History

I faced lots of issues due to this update. To figure out the issue I spent the hours.
After that I finalized to downgrade the wordpress version to 3.4.2

WordPress really did something messy in this release.

I downgraded my wordpress 3.5 to 3.4.2 wordpress release. Now my sites are stable.
I took help from following articles.

http://iblog4dollars.com/2013/01/02/wordpress-problems-how-to-downgrade-from-wordpress-3-5/

Some points are not mentioned in above article. Which is as follows:
Keep your wp-config.php, .htaccess and robots.txt file
Do not forget about sitemap.xml files.

wordpress 3.5 is Worst Update in Wordpess release History
wordpress 3.5 is Worst Update in Wordpess release History

Do not use many wordpress plugins in website for SEO

Do not use many wordpress plugins in website for SEO. Plugin will slow down your wordpress site. There are several nice plugins also which we need to use.. There are so many wordpress plugins which are free to download. There are more than 21500 wordpress plugins till date of jan 2013. There are several nice plugins also which we need to use.

Do not use many wordpress plugins in website for SEO

You can refer following articles.

  1. Best wordpress plugins for wordpress security and protection
  2. wordpress plugins for stats or statistics
  3. 16 Best WordPress Plugins which every WordPress Blog Should install

If you use many plugins then slow down the site

You have more than 30+ plugins then that plugin will execute the extra sql queries while opening each and every page. Depends on your wordpress plugins which is installed on your site. your site load slowly.

Some free plugins will ad the unnecessary code in your site

Some wordpress plugins add the some unnecessary JavaScript and PHP code to your site. Some plugins will use your site for their advertising purpose. So first check the plugin review.

Some wordpress plugins are not safe to install

Some wordpress plugins are not secured to install in site. It may cause the security issue. Some plugins are easy target for hackers. You should read the some review about plugin before start using in your site.

Some wordpress plugin will cause issues in your site

Before installing the wordpress plugins you should create development or test site and on development site you should first try to install the new wordpress plugins. After that you should install on current site. Some plugins will cause the jQuery conflicts in your site.

Do not use many wordpress plugins in website for SEO
Do not use many wordpress plugins in website for SEO

How to wordpress add javascript to page template

For many purpose and designs we use the page template in wordpress site. WordPress tutorial for, How to wordpress add javascript to page template. Some time we need to load the custom javascript to page template. Here is code for same.

How to wordpress add javascript to page template

For that we can use following code.

add_action('wp_enqueue_scripts','Load_Template_Scripts_wpapi');
function Load_Template_Scripts_wpapi(){
    if ( is_page_template('custom-page.php') ) {
        wp_enqueue_script('my-script', 'path/to/script.js');
    }
}

For loading any script or any custom code you can use above action in wordpress. Above code you need to add in functions.php file. Which you can find in your wordpress theme folder.

How to wordpress add javascript to page template
How to wordpress add javascript to page template

How to use category wise background images in wordpress

WordPress has category feature, We can use the wordpress category for many purpose. Given plugins list to use category wise background images in wordpress.

Some time we want use category images for show the category content. Some time we want use the category wise background images in your website.

How to use category wise background images in wordpress

For category images you can use the some nice wordpress plugins.

The Categories Images Plugin allow you to add image with category or taxonomy.

Using this plugin, you can add icons (images) to sidebar of your site or blog into section of categories and pages.

For category background images you need know about body_class() method. Detailed information you can find on following page.

Body_class()

If you have wpapi category then you can use following CSS.

  • If they are there, you can use these as selectors in your CSS: body.category-wpapi { /* code here */ }, etc.
  • If not, add the body_class() function to the tag in your theme, probably located in header.php. It works like this:
    <body <?php body_class(); ?>>
How to use category wise background images in wordpress
How to use category wise background images in wordpress

How to save metadata in wordpress custom post type

Custom post type are very important in wordpress. Code for save metadata in wordpress custom post type. There are some plugins for creating the post type but I recommend custom code in function.php file.

How to save metadata in wordpress custom post type

I already written about custom post type. If you want to know about custom post type in detail then you can use following articles.

Here in this tutorial I showed How to save the meta data for your custom post type.

add_action( 'add_meta_boxes', 'job_detail_box' );

function job_detail_box() {
add_meta_box(
'job_detail_box',
__( 'job Detail', 'myplugin_textdomain' ),
'job_detail_box_content',
'job',
'normal',
'high'
);
}

function job_detail_box_content( $post ) {
// No need to globalise a post that is an argument on this callback
$meta_p = get_post_meta($post->ID, "jobs_price", true);
$meta_l = get_post_meta($post->ID, "jobs_location", true);

echo '<input type="hidden" name="jobs-nonce" id="jobs-nonce" value="' . wp_create_nonce( 'jobs-nonce' ) . '" />';

?>
<div>
<ul>

<ul>

<ul>
	<li><label>job Price</label>php echo $meta_p; ?>" /></li>
</ul>

</ul>

<ul>

<ul>
	<li><label>job Location</label>php echo $meta_l; ?>" /></li>
</ul>

</ul>

</ul>
</div>
<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
}

add_action ('save_post', 'save_jobs');

// The save_post hook provides the post id to the return function
function save_jobs( $post_id ){

if ( !wp_verify_nonce( $_POST['jobs-nonce'], 'jobs-nonce' )) {
return $post_id;
}

if ( !current_user_can( 'edit_post', $post_id ))
return $post_id;

update_post_meta($post_id, "jobs_price", $POST['jobs_price'] );
update_post_meta($post_id, "jobs_location", $POST['jobs_location'] );
}

How to save the meta data in wordpress custom post type
How to save the meta data in wordpress custom post type

	

how to stop wordpress spam comments and increase SEO

WordPress tutorial, how to stop wordpress spam comments and increase SEO. Spam comments is really major issue. Spam comments will affect your site SEO.
You should delete the spam word comments from wordpress site.

how to stop wordpress spam comments and increase SEO

If you want to prevent spam comments wordpress.  You can check more points and wordpress plugins which will be helpful for wordpress websites.

If you have approved spam comments already than you can use following SQL query to change some spam comments status.

Using following sql query you can unapprove spam comments which are already approved.


Update wp_comments set comment_approved=0 WHERE CHAR_LENGTH(comment_author_url)>35;
Update wp_comments set comment_approved=0 WHERE CHAR_LENGTH(comment_author)>30;

 

After this, you can again recheck the comments which might be spam.

For SEO of your site deleting spam word comments is good.

Here are some steps for protecting your wordpress site.

You may copy and paste the following list to the Comment Moderation box in your wp-admin/options-discussions.php page:

  • -online
  • 4u
  • adipex
  • advicer
  • baccarrat
  • blackjack
  • bllogspot
  • booker
  • byob
  • car-rental-e-site
  • car-rentals-e-site
  • carisoprodol
  • casino
  • casinos
  • chatroom
  • cialis
  • coolcoolhu
  • coolhu
  • credit-card-debt
  • credit-report-4u
  • cwas
  • cyclen
  • cyclobenzaprine
  • dating-e-site
  • day-trading
  • debt-consolidation
  • debt-consolidation-consultant
  • discreetordering
  • duty-free
  • dutyfree
  • equityloans
  • fioricet
  • flowers-leading-site
  • freenet-shopping
  • freenet
  • gambling-
  • hair-loss
  • health-insurancedeals-4u
  • homeequityloans
  • homefinance
  • holdem
  • holdempoker
  • holdemsoftware
  • holdemtexasturbowilson
  • hotel-dealse-site
  • hotele-site
  • hotelse-site
  • incest
  • insurance-quotesdeals-4u
  • insurancedeals-4u
  • jrcreations
  • levitra
  • macinstruct
  • mortgage-4-u
  • mortgagequotes
  • online-gambling
  • onlinegambling-4u
  • ottawavalleyag
  • ownsthis
  • palm-texas-holdem-game
  • paxil
  • penis
  • pharmacy
  • phentermine
  • poker-chip
  • poze
  • pussy
  • rental-car-e-site
  • ringtones
  • roulette
  • shemale
  • shoes
  • slot-machine
  • texas-holdem
  • thorcarlson
  • top-site
  • top-e-site
  • tramadol
  • trim-spa
  • ultram
  • valeofglamorganconservatives
  • viagra
  • vioxx
  • xanax
  • zolus

There are some nice plugins also which is helpful for protecting your site from spam comments.
You should activate the Akismet wordpress plugin.
Akismet is quite possibly the best way in the world to protect your blog from comment and trackback spam. It keeps your site protected from spam even while you sleep.

You should check the following option from wordpress:

Before a comment appears: (Options)

  1. Before a comment appears An administrator must always approve the comment
  2. Comment author must have a previously approved comment

If you have many spam word comments in your site then you should use sql query for delete the spam comments.

DELETE FROM wp_comments WHERE comment_content LIKE '%<a%';
DELETE FROM wp_comments WHERE comment_author LIKE '%<a%';
DELETE FROM wp_comments WHERE comment_author_url LIKE '%health%';

You should replace the spam comments words in SQL query. Using above sql query you can delete the all spam word comments.

For SEO purpose following options are very important.

how to stop wordpress spam comments and increase SEO
how to stop wordpress spam comments and increase SEO