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.

add wordpress plugin header image in WordPress Plugins listing

WordPress tutorial for plugin developers, add wordpress plugin header image in WordPress Plugins listing page. wordpress is allowing to add header image. This is very old thing still I am bringing up again. From Jan 2012 wordpress is allowing to add the wordpress plugin header image in wordpress plugin listing.

add wordpress plugin header image in WordPress Plugins listing

After adding image to assets folder to SVN root. Plugin image will appear after half hour.

To add your own header image to your plugins, follow http://make.wordpress.org/core/2011/12/21/been-giving-a-lot-of-thought-to-how/ Matt’s instructions on the dev blog. Images must be 772 by 250 pixel JPEG or PNG files. And no animated GIFs, kids.

As an experiment we’ve turned on custom hThis is very old thing still I am bringing up again. From Jan 2012 wordpress is allowing to add the wordpress plugin header image in wordpress plugin listing.

After adding image to assests folder to SVN root. Plugin image will appear after half hour.

To add your own header image to your plugins, follow http://make.wordpress.org/core/2011/12/21/been-giving-a-lot-of-thought-to-how/ Matt’s instructions on the dev blog. Images must be 772 by 250 pixel JPEG or PNG files. And no animated GIFs, kids.

As an experiment we’ve turned on custom headers for the plugin directory. If you’d like to try out this feature:

Make a 772×250 pixel jpeg or png. (No animated GIFs. 🙂 )
Check it in to your plugin’s SVN directory with the path assets/banner-772×250.(jpg|

png). Note that the assets directory is added to your plugin’s root directory, not trunk.
On the next plugin directory refresh (every 15 minutes or so) you should see your image start showing up on the page.

eaders for the plugin directory. If you’d like to try out this feature:

Make a 772×250 pixel jpeg or png. (No animated GIFs. 🙂 )
Check it in to your plugin’s SVN directory with the path assets/banner-772×250.(jpg|

png). Note that the assets directory is added to your plugin’s root directory, not trunk.
On the next plugin directory refresh (every 15 minutes or so) you should see your image start showing up on the page.
add wordpress plugin header image in WordPress Plugins listing
add wordpress plugin header image in WordPress Plugins listing

how to crop uploaded image in wordpress without plugin

Many people use the scaled image for thumbnail image. Instead of that croping image the proper size and showing that is nice. Crop Uploaded image without plugin is supported by wordpress itself so do not use any third-party plugin for this.

crop uploaded image in wordpress

You can use the following code in your functions.php file:

// Standard Size Thumbnail
if(false === get_option("thumbnail_crop")) {
 add_option("thumbnail_crop", "1"); }
 else {
 update_option("thumbnail_crop", "1");
 }

// Medium Size Thumbnail
if(false === get_option("medium_crop")) {
 add_option("medium_crop", "1"); }
 else {
 update_option("medium_crop", "1");
 }

// Large Size Thumbnail
if(false === get_option("large_crop")) {
 add_option("large_crop", "1"); }
 else {
 update_option("large_crop", "1");
 }
crop uploaded image in wordpress without plugin
crop uploaded image in wordpress without plugin

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.

Show QR code in your wordpress post

QR codes are digital information which will be stored in image format. Many people are showing the QR code image in there site. You can very easily show the chart qr image in your post.

Show QR code in your wordpress post

You need to use the following code in your single.php file.

<img src="https://chart.googleapis.com/chart?cht=qr&chs=250x250&chl=<!--?php the_permalink(); ?-->" alt="QR: <!--?php the_title(); ?-->"/>
Show QR code in your wordpress post
Show QR code in your wordpress post

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

Disable comments on posts after certain comment count

Many people want to disable the post comments for some posts which has too many comments. Using simple code you can easily disable the comments for your posts which has many comments.

Here I written simple code. Using following code you can disable the comments which posts has more than 100 comments. you need to just put following code into your functions.php file.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
$comment_count = 100;
function disable_comments( $posts ) {
 if ( !is_single() ) { return $posts; }
 if ( $posts[0]->comment_count > $comment_count ) {
 $posts[0]->comment_status = 'disabled';
 $posts[0]->ping_status = 'disabled';
 }
return $posts;
}
add_filter( 'the_posts', 'disable_comments' );
?>
Disable comments on posts after certain commment count in wordpress
Disable comments on posts after certain commment count in wordpress

how to get current user information in wordpress

In wordpress current user means, Who written current post or article.In this article we are going show you, how to get current user information in wordpress. Following methods are useful when user are logged in to wordpress CMS.

You can print the user information using following information. Retrieves the information pertaining to the currently logged in user, and places it in the global variable $current_user.

how to get current user information in wordpress

You can put following code in your theme folder.

<?php 

global $current_user;
 get_currentuserinfo();
 echo 'Username: ' . $current_user->user_login . "\n";
 echo 'User email: ' . $current_user->user_email . "\n";
 echo 'User first name: ' . $current_user->user_firstname . "\n";
 echo 'User last name: ' . $current_user->user_lastname . "\n";
 echo 'User display name: ' . $current_user->display_name . "\n";
 echo 'User ID: ' . $current_user->ID . "\n";
?>

Or you can use following code for showing the current user information

<?php&nbsp;
wp_get_current_user();&nbsp;
?>  

<?php
$user_info = get_userdata(1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'Username: ' . $user_info->user_login . "\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'User roles: ' . implode(', ', $user_info->roles) . "\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'User ID: ' . $user_info->ID . "\n";
?>

For more detailed information you can visit following link:
http://codex.wordpress.org/Function_Reference/get_userdata

how to get current user information in wordpress
how to get current user information in wordpress

How to create custom shortcode for wordpress site

There are many wordpress plugins which using the shortcode. But you easily create custom shortcode for wordpress site. there is no need of external plugin.

custom shortcode for wordpress

Since Version 2.5 WordPress support so called Shortcodes. They have been introduced for creating macros to be use in a posts content. Many people looking for how to create the shortcode in wordpress using theme. It is very easy to build shortcode in wordpress. I given very simple code sample for creating the custom shortcode.

For more information visit following page.

For creating the custom shortcodes you need add following method in functions.php file which is located in your theme folder.


function myshortcode(){
 return '<img src="http://images.purabtech.in/How-to-make-empty-the-wordpress-trash-automatically.png">';
}
add_shortcode('myshortcode', 'myshortcode');

custom shortcode for wordpress
custom shortcode for wordpress

you can change the return text or shortcode name aslo.