how to check custom post type in wordpress

wordpress tutorial, how to check custom post type in wordpress. Many we want to execute some code on custom post type or want to execute code on post. Many we want to execute some code on custom post type or some times we want to execute code on normal pages or post.

how to check custom post type in wordpress

So here is solution. You just need to just add following code into your functions.php file which you can find in your wordpress theme folder.

function check_custom_post_type() {
global $wp_query;

$post_types = get_post_types(array('public'   => true,'_builtin' => false),'names','and');

foreach ($post_types  as $post_type ) {
if (get_post_type($post_type->ID) == get_post_type($wp_query->post->ID)) {
return true;
} else {
return false;
}
}
}

After this you can use following function in any wordpress file. For example you can use this method in single.php file.

if (check_custom_post_type()) {
//Current post is a custom post type
}
how to check custom post type in wordpress
wordpress tutorial, how to check custom post type in wordpress. Many we want to execute some code on custom post type or want to execute code on post.

best wordpress seo plugins ever which will increase site seo

Normally people searching for best wordpress seo plugins,  I shortlised best wordpress seo plugins which are really useful for every wordpress developers.

I am using wordpress since 2006 for my blogs and websites. Since I also written the wordpress plugins for SEO purpose. Still some wordpress plugins are really doing great work. SEO is very import facter for every website.

best wordpress seo plugins

I almost used every best wordpress seo plugins But I like following wordpress plugins due to some reasons. Personally I like the “WordPress SEO by Yoast” wordpress plugin for SEO purpose. It is simple to use. It is not impacting on your site performance. It takes less then 40% memory as compare the other seo plugins. Site performance is very for every website seo. Meta description and meta tags and seo title are equally important.

Smart WordPress SEO

Boost your wordpress SEO: Full SEO features Meta Tags, webmaster tools settings, Social AuthorShip for Facebook, Twitter and Google Plus and XML sitemap

You can enter your meta keywords and description for your homepage and each post and pages.

This plugin will add different Meta description for each individual post as your excerpt of your post.

This will help your blog to rank better in google. You can easily increase your blog traffic using this plugin.

Following are the features:

  1. Preview of Smart wordpress SEO – Home page Keywords and description
  2. WebMaster Tool Verification Setting
  3. Social Authorship for Google, Twitter and Facebook
  4. XML sitemap setting
  5. Image SEO setting
  6. Eash Post or Page SEO title, Description and Keywords setting

WordPress SEO by Yoast

best wordpress seo plugins ever which will increase site seo
best wordpress seo plugins ever which will increase site seo

Improve your WordPress SEO: Write better content and have a fully optimized WordPress site using the WordPress SEO plugin by Yoast.

Comments: This is very nice plugin for SEO. It takes less memory as compare to other best wordpress seo plugins. I personally using this plugin in my site. This plugin has not many features like other best wordpress seo plugins but this plugin is really fast. No memory leak issues with this plugin.

SEO Ultimate

SEO Ultimate,best wordpress seo plugins
SEO Ultimate,best wordpress seo plugins

This all-in-one SEO plugin gives you control over title tags, noindex, meta tags, Open Graph, slugs, canonical, autolinks, 404 errors, rich snippets,

Comments: I love this plugin. This plugins I used for years. If you have good hosting solution then you should go for this plugin for seo. This is best ever and great plugin for seo. But only bad part is It takes lot of memory of your site almost 30% of memory will consumed by this plugin while each page loading. Still I can recommend this plugin for SEO because It has really great result in SEO with wordpress.

All in One SEO Pack

All in One SEO Pack,best wordpress seo plugins
All in One SEO Pack,best wordpress seo plugins

WordPress SEO plugin to automatically optimize your WordPress blog for Search Engines.

Comments: This plugin is really oldest great seo tool for wordpress. This plugin I used for some time. It has great features. Helpful to SEO. Many bloggers are still loving this wordpress plugin and using it. This plugin also consume your server memory big time while each page loading. Performance is  very important when you are using any wordpress plugin.

My SEO Plugin

Seo Meta Tags

You can enter your meta keywords and description for your homepage. Same like best wordpress seo plugins, this is also great and simple and very light seo plugin which is written by me.
This plugin will add different Meta description for each individual post as your excerpt of your post. This will help your blog to rank better in google. You can easily increase your blog traffic using this plugin.

Comments: This plugin has minimal features for SEO but still most important seo features are present in this plugin. This plugin will not consume your site memory. This plugin is super fast. This plugin is very easy to use in your site. They looked for performance of site. Using this plugin you can increase the seo without effecting the site performance.

What People are doing for SEO

Normally people are searching for best wordpress seo plugins, install wordpress seo plugins,  all in one seo wordpress plugin, wordpress seo optimization, yoast seo, wp seo plugin, all in one seo vs yoast,  seo ultimate vs yoast. I shortlised the best ever wordpress seo plugin which are really useful for every wordpress developers. If you have doubts about wordpress SEO then you can write to me.

show related posts wordpress without plugin using category

How to show related posts wordpress without plugin using category. Showing related article in wordpress site is always good for users to attract visitors.  In many blogs people are showing the related or linked articles. Showing similier or related articles will increaze your site SEO. show related posts without wordpress plugin using category in wordpress site is always good for users to attract the visitors.

show related posts wordpress without plugin

More visitor will visit your site. For showing the related articles you need copy following code into your functions.php file.

[viral-lock message=”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.”]

// "Similier Articles"
function wpapi_more_from_cat( $title = "Similier Articles:" ) {
    global $post;
    // We should get the first category of the post
    $categories = get_the_category( $post->ID );
    $first_cat = $categories[0]->cat_ID;
    // Let's start the $output by displaying the title and opening the <ul>
    $output = '<h3>' . $title . '</h3>';
    // The arguments of the post list!
    $args = array(
        // It should be in the first category of our post:
        'category__in' => array( $first_cat ),
        // Our post should NOT be in the list:
        'post__not_in' => array( $post->ID ),
        // ...And it should fetch 5 posts - you can change this number if you like:
        'posts_per_page' => 5
    );
    // The get_posts() function
    $posts = get_posts( $args );
    if( $posts ) {
        $output .= '<ul>';
        // Let's start the loop!
        foreach( $posts as $post ) {
            setup_postdata( $post );
            $post_title = get_the_title();
            $permalink = get_permalink();
            $output .= '
<ul>
	<li>permalink . '" title="' . esc_attr( $post_title ) . '">' . $post_title . '</li>
</ul>
';
        }
        $output .= '</ul>';
    } else {
        // If there are no posts, we should return something, too!
        $output .= '<p>Sorry, this category has just one post and you just read it!</p>';
    }
    echo $output;
}

[/viral-lock]

After that open your single.php file and use following code.

wpapi_more_from_cat();
show related posts wordpress without plugin
show related posts wordpress without plugin

Using above code you can show the related articles in your wordpress site.

How to wordpress secure file upload using apache rules

WordPress tutorial, How to wordpress secure file upload using apache rules, Here we given apache rule for secure your wordpress file upload functionality.

How to wordpress secure file upload using apache rules

Website security is most important point of any website. In wordpress we need to give 777 permission to wp-content/uploads folder. Some time we don’t want to give the 777 (read, write and execute) permission to folder due to security reason but wordpress do not allow you to upload images or media files to uploads folder.

Tip: Do not give 777 permission to wp-content/uploads folder. In stead change user ownership to apache folder.

Security

What you can do is. You can restrict other file types to upload in uploads folder using simple apache rule. following code you can use in .htaccess file.


	Order Allow,Deny
	Deny from all

<FilesMatch ".(jpg|jpeg|jpe|gif|png|tif|tiff)$">
	Order Deny,Allow
	Allow from all

Using above code you can secure your uploads folder and only selected files can be pushed into uploads folder.

How to wordpress secure file upload using apache rules
How to wordpress secure file upload using apache rules

Display the authors in dropdown menu using wp_dropdown_users – Hook/Filter

One of my client faced issue with Autor drop down which is in Admin section.

Display the authors in dropdown menu using hooks.

While creating the New post there was problem with the Author field. There are hundreds of irrelevant selections (users) and it’s difficult to select the right one.

WordPress is by default showing all the users in author drop down. I don’t want to show the other users in author drop down.

Display the authors in a dropdown menu
Hook/Filter – In wordpress Admin -Add new Post section -Display the authors in a dropdown menu using wp_dropdown_users One of my client faced issue with Autor drop down which is in Admin section. Display the authors in a dropdown menu using hooks

I searched for wp_dropdown_users hook or filter. But I did not found any proper solution.

Following articles are found helpful to me.
http://wordpress.org/support/topic/filter-for-post-quick-edit-author-drop-down
http://codex.wordpress.org/Function_Reference/wp_dropdown_users

Using that code I modified the code and I am able to fix the issue. You can put following code in to functions.php file.

 /*
 * Hook for showing Admin and Author in Add new Post - Admin section dropdown menu
 */
function wpapi_override_wp_dropdown_users($output) {
    global $post, $user_ID;
    //get the Admin-role users IDs
    $admins = getUsersWithRole('admin');
    //get the author-role users IDs
    $authors = getUsersWithRole('author');
    //merge the array
    $result = array_merge($admins, $authors);

    //array converted into comma seprated string
    $authorsall = implode(",", $result);

    // return if this isn't the theme author override dropdown
    if (!preg_match('/post_author_override/', $output))
        return $output;

    // return if we've already replaced the list (end recursion)
    if (preg_match('/post_author_override_replaced/', $output))
        return $output;

    // replacement call to wp_dropdown_users
    $output = wp_dropdown_users(array(
        'echo' => 0,
        'name' => 'post_author_override_replaced',
        'selected' => empty($post->ID) ? $user_ID : $post->post_author,
        'include_selected' => true,
        'include' => $authorsall
    ));

    // put the original name back
    $output = preg_replace('/post_author_override_replaced/', 'post_author_override', $output);

    return $output;
}

add_filter('wp_dropdown_users', 'wpapi_override_wp_dropdown_users');

/*
 * Find User IDs by Role
 */

function getUsersWithRole($role) {
    $wp_user_search = new WP_User_Search($usersearch, $userspage, $role);
    return $wp_user_search->get_results();
}

Using above code, you can load multiple role users in author drop down.

use animated smileys and emoticons in wordpress post

Smiles and emoticons are always important show your expressions in short way. Earlier also I posted articles about same. Here is link about that. here in this article written about animated smileys. I given very detailed information to use animated smileys and emoticons in wordpress. animated smilyes and emotions are used everywhere now in mobile device.

use animated smileys and emoticons in wordpress

By default wordpress supports some basic emoticons. Here I can suggest some very cool wordpress plugins.

Kaskus Emoticons

Kaskus Emoticons is an emoticon set inspired by Kaskus, the Largest Indonesian Community – consisting of over a million active members from all over the world. The images which are used in this plugin are copyright of Kaskus

Speedy Smilies

Speedy Smilies takes emoticons in WordPress to the next level (where it should be already and hopefully one day will). The end goal is to make smilies load faster in the browser for visitors and make them easy to insert into posts/pages for authors. In addition to the speed benefits, Speedy Smilies allows authors to easily change the appearance of emoticons using smiley sets.

Speedy Smilies is free software licensed under the GNU GPL version 3.

Tango Smileys Extended

Tango Smileys Extended (TSE) disables the built-in WordPress smileys and extends the number of available smileys from 18 to 202. The extended smileys can be input using standard emoticon shorthand, or through the CTI (Click to Insert) interface. Smileys in comments is supported and may be inserted using the standard emoticon shorthand or through the CTI interface. MCEComments is also supported.

This version of Tango Smileys Extended is for WordPress 2.8+
WordPress versions pre-2.8 are no longer supported. If you are using WordPress 2.7.x, please use Tango Smileys Extended 2.5.4.1. WordPress 2.6.x and earlier are only supported in versions of Tango Smileys Extended older than, and including, 2.5.2.8.

Moods Addon for Ultimate TinyMCE

This plugin is designed to be used as an add-on to my Ultimate TinyMCE plugin. However, it can also be used as a stand-alone plugin as well.

For best results; You can download Ultimate TinyMCE here:
http://wordpress.org/extend/plugins/ultimate-tinymce/

This addon will add a button to your visual tinymce editor for posts/pages. Clicking the button will open a popup window with over 50 professionally animated .gif smiley’s.

You can insert these smiley’s into your post/page content areas. Simply click a smiley, and it is automatically inserted into your content area.

Font Emoticons

Replaces WordPress’ smileys (based on images) with font-based emoticons (see screenshots). Font-based emoticons have some advantages:

  • They have the same size as the surrounding text. No more distorting the heights of lines containing smileys/emoticons. They always fit the font size.
  • They have the same color as the surrounding text.

The following emoticons are supported:

  • :) :-) :smile:
  • :( :-( :sad:
  • ;) ;-) :wink:
  • :P :-P :razz:
  • -.- -_- :sleep:
  • :thumbs: :thumbsup:
  • :devil: :twisted:
  • :o :-o :eek:
  • 8O 8o 8-O 8-o :shock: (No real icon for “shock” yet. Using “eek” instead.)
  • :coffee:
  • 8) 8-) B) B-) :cool:
  • :/ :-/
  • :beer:
  • :D :-D :grin:
  • x( x-( X( X-( :angry:
  • :x :-x :mad: (No real icon from “mad” yet. Using “angry” instead.)
  • O:) 0:) o:) O:-) 0:-) o:-) :saint:
  • :'( :'-( :cry:
  • :shoot:
  • ^^ ^_^ :lol:

Notes: * Emoticons must be surrounded with spaces (or other white space characters); e.g. the emoticon in that:)smile won’t be replaced * Emoticons won’t be replaced in HTML tags nor in <pre> or <code> blocks.

wp-Monalisa

wp-monalisa is the plugin that smiles at you like monalisa does. place the smilies of your choice in posts, pages or comments.

There are a lot plugins for smiley support out there and some of them are really useful. Most of them don’t work out of the box and this is what wp-monalisa tries to achieve, giving you the ability to maintain your smilies and even turn them into img tags.

it’s easy and it smiles at you…what else do you want?

Features:

  • maintain your smilies in a separate directory
  • activate or deactivate smilies for posts or comments
  • replace smilies with img tags
  • extend or replace wordpress smiley replacement
  • while edit posts or pages, pops-up in a draggable meta-box
  • extends your comment form to give you visitors the freedom to smile 🙂
  • support for fckeditor (tested with v3.3.1)
  • fully integrated ith BuddyPress
use animated smileys and emoticons in wordpress post
use animated smileys and emoticons in wordpress post

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

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 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

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