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.

disable image upload for wordpress users

wordpress tutorial, disable image upload for wordpress users. If you want to restrict the normal author to upload media file your wordpress blog.  So you can use the following code in your functions.php file.

disable image upload for wordpress users

disable image upload for wordpress users
disable image upload for wordpress users

Following function will remove the upload media button from wordpress dashboard.


//remove the upload buttons for auther and other wordpress user
function removemediabuttons()
{
if($user-&amp;gt;wp_user_level &amp;gt;= 1) {
remove_action( 'media_buttons', 'media_buttons' );
}

}
add_action('admin_head','removemediabuttons');

Following code will remove the media library tab from the Add new post section for all the users.
Restricts media library access (subscriber) under the “add new post”

function remove_medialibrary_tab($tabs) {
unset($tabs['library']);
return $tabs;
}
add_filter('media_upload_tabs','remove_medialibrary_tab');

This hack is very important for wordpress developers. when you are developing the multiuser wordpress site.

how to hide wordpress login page error messages

wordpress tutorial, how to hide wordpress login page error messages. Here in this article We are Hiding wordpress dashboard login error is very basic thing for keep away hackers.

how to hide wordpress login page error messages
how to hide wordpress login page error messages

Hiding wordpress dashboard login error is very basic thing for keep away hackers. Whenever you and any hackcer are trying to login using the correct username but with the wrong password, that will give you a message saying “Error: Incorrect Password.” hacker will got the clue that the username entered is in the system, and that they simply need to crack its password. Same with username also you will got following message.
“Error: Invalid username”
For avoiding this thing you just need to open your functions.php file and put the following code in that file

add_filter('login_errors', create_function('$a', "return null;"));

This hack will remove the WordPress error by displaying nothing when a login is incorrect.

 

Updating the wordpess to wordpress 3.0.4 is important

Today I got email from Matt saying wordpress 3.0.4 version is released and we must need to update the wordpress due the major security reasons. When I checked the following article I realized the how important is wordpress 3.0.4 version.

http://wordpress.org/news/2010/12/3-0-4-update/

What Matt is saying at the end of 2010

My last message to you this year is an important but unfortunate one: we’ve fixed a pretty critical vulnerability in WordPress’ core HTML sanitation library, and because this library is used lots of places it’s important that everyone update as soon as possible.

I realize an update during the holidays is no fun, but this one is worth putting down the eggnog for. In the spirit of the holidays, consider helping your friends as well.

You can update in your dashboard, on the “updates” tab, or download the latest WordPress here:

Download

wordpress 3.0.4
wordpress 3.0.4

What Major Changes wordpress did in this 3.0.4 version.

They resolved following issue:

Don’t be case sensitive to attribute names. Handle padded entities when checking for bad protocols. Normalize entities before checking for bad protocols in esc_url(). Props Mauro Gentile, duck_, miqrogroove

WordPress changes the following files.

  • wp-includes/formatting.php
  • wp-includes/kses.php

how to create simple shadow effect in photoshop

photoshop tutorial, how to create simple shadow effect in photoshop. we given step by step guide with screen shots and their details.

how to create simple shadow effect in photoshop

how to create simple shadow effect in photoshop
how to create simple shadow effect in photoshop

Create your own design in photoshop

Type a text as a “wordpressapi”

photoshop_shawdo

now select filter option >> artistic >> corked pencil

it will look like below

photoshop3

Now select >> layer style >>  blending option

select drop shadow

photoshop4

timthumb php script for image resizing with wordpress

wordpress tutorial, timthumb php script for image resizing with wordpress. We all know what is the tumthumb script. mainly the worpdress theme developers used the tumthumb php script for resizing the images.

timthumb php script for image resizing with wordpress

But now we dont need to use the tumthumb script in wordpress theme because wordpress api is supporting the similier functionality in wordpress.

Using the wordpress hook we can specify the thumbnail size.

You can set the post image thumbnail size using wordpress hook.

Just copy paste the following code in to your functions.php file


function custom_thumbnail_size() {
return 128; // or whatever you want
}
add_filter('wp_thumbnail_max_side_length','custom_thumbnail_size');

timthumb php script for image resizing with wordpress
timthumb php script for image resizing with wordpress

How to add custom text in every wordpress post

wordpress tutorial, How to add custom text in every wordpress post. There is always common content we want put in every post. using following function we can add the custom text in every wordpress post.

How to add custom text in every wordpress post

just open your functions.php file from wordpress theme folder and put the following code in that file.


function mytext($content)
{
return "The addtional content goes here: ".$content;
}
add_filter('the_content', 'mytext');

How to add custom text in every wordpress post
How to add custom text in every wordpress post

wordpress get posts with custom field value

wordpress tutorial, wordpress get posts with custom field value. Many people use the custom meta fields in wordpress posts. Here given code snippet for same.  In this article I will show you how to retrieve the custom field from wordpress post. For fetching the custom fields you just need to use the following code.

wordpress get posts with custom field value

$key_values = get_post_meta($post-&gt;ID, 'key');
custom meta tags
wordpress get posts with custom field value

If you are using normal post or custom post type above function will work. Here is another code for fetching the custom post type meta values.

$loop = new WP_Query( array( 'post_type' =&gt; 'product', 'posts_per_page' =&gt; 10 ) );
while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post();
the_title();
the_content();
global $post;
$custom = get_post_custom($post-&gt;ID);
echo $thumbnail_url = $custom["thumbnail_url"][0];
echo $product_info = $custom["product_info"][0];
echo '
<div>';
the_content();
echo '</div>
';
endwhile;