show tweetmeme button and facebook share button

I created custom wordpress theme. In that theme I am using the_excerpt method for showing the post on some pages.
I installed the tweetmeme and facebook-share-new plugins and activated on wordpress site.
I saw one issue with these plugins. These plugins are showing on only single pages or posts.

show tweetmeme button and facebook share button
show tweetmeme button and facebook share button

Facebook and twitter button are not showing when I am using the the_excerpt() function.

I tried google but I did not got any suaitable answer. Everybody is saying about do mannual work when we creating the post.

So did checked the these plugins and I found the solution.

First I am taking about tweetmeme plugin. I opened the “tweetmeme.php” file. This file you will find in wordpress plugins and tweetmeme folder.

Add following code to line no 721 and comment the following line.

add_filter(‘the_excerpt’, ‘tm_update’);
//add_filter(‘get_the_excerpt’, ‘tm_remove_filter’, 9);

Add following code to line no 129
remove_action(‘the_excerpt’, ‘tm_update’);
tweetmeme
When you done with changes you will be able to see tweetmeme button with wordpress post excerpt also.

Updated tweetmeme.php file you can download from here. Please right click and choose save as option.

Now I am going to talk about facebookshare plugin. I opened the facebookshare.php file. This file you will find in wordpress plugins facebook-share-new folder.

Add following code to line no 843

add_filter(‘the_excerpt’, ‘fb_share’);

When you done with changes you will be able to see facebookshare button with wordpress post excerpt also.

Updated facebookshare.php file you can download from here. Please right click and choose save as option.

457 Free WordPress Themes amazing, High quality

Here are links for 457 Free WordPress Themes amazing, High quality. I searched on smashingmagzine site I found about 457 wordpress themes. which all are chosen and good.

457 Free WordPress Themes amazing, High quality

URLs for as follows:

http://www.smashingmagazine.com/2009/05/18/100-amazing-free-wordpress-themes-for-2009/

http://www.smashingmagazine.com/2008/01/08/100-excellent-free-high-quality-wordpress-themes/

http://www.smashingmagazine.com/2009/11/12/40-free-high-quality-wordpress-themes/

http://www.smashingmagazine.com/2007/03/29/8-fresh-and-clean-wordpress-themes/

http://www.smashingmagazine.com/2008/03/25/15-more-free-first-class-wordpress-themes/

http://www.smashingmagazine.com/2008/08/25/30-free-high-quality-wordpress-themes/

http://www.smashingmagazine.com/2007/02/09/83-beautiful-wordpress-themes-you-probably-havent-seen/

http://www.smashingmagazine.com/2007/08/28/45-excellent-blog-designs/

http://www.smashingmagazine.com/2007/06/26/21-fresh-usable-and-elegant-wordpress-themes/

http://www.smashingmagazine.com/2007/05/07/10-fresh-elegant-and-clean-wordpress-themes/

wordpress-logo-shine

 

Have fun!

Solved: header function issue with WordPress

we solved header function issue with WordPress. If you are facing issue with redirecting the one page or post to another page.

All PHP programmer always first try header() function. But when you use header function in worpdress that will not allow you to redirect the page.

Solved: header function issue with WordPress

Instead of using the header function please use wp_redirect() function which is provided by WordPress API.

<?php

global $post; // if outside the loop

if ( is_page() && $post->post_parent ) {

// This is a subpage

wp_redirect(get_option(‘siteurl’) . ‘/wp-login.php’);

} else {

// This is not a subpage

wp_redirect(get_option(‘siteurl’) . ‘/wp-login.php’);

}

?>

Use following URLs for reference.

http://codex.wordpress.org/Conditional_Tags

http://codex.wordpress.org/Function_Reference/wp_redirect

Solved for WordPress old and new versions - PHP Fatal error: Allowed memory size of 33554432 bytes exhausted
Solved for WordPress old and new versions – PHP Fatal error: Allowed memory size of 33554432 bytes exhausted

How to remove curly quotes from WordPress post

While doing the copy and paste from any website is always problem. While coping the code. curly quotes come and you want to convert that into straight quotes. Some time you want to remove curly quotes from WordPress post title or body.

How to remove curly quotes from WordPress post Title and body.

Here we have given following code which can be useful. The apostrophe should be straight not curly in WordPress.

Just Open your functions.php file from your theme folder. If you did not created functions.php file then you can paste this code in your header.php file.

remove_filter('comment_text', 'wptexturize');
remove_filter('the_title', 'wptexturize');
remove_filter('the_content', 'wptexturize');

This will solve your problem.

How to remove curly quotes and use straight quotes then use following code.

function removesmartquotes($content) {
$content = str_replace('&#8220;', '&quot;', $content);
$content = str_replace('&#8221;', '&quot;', $content);
$content = str_replace('&#8216;', '&#39;', $content);
$content = str_replace('&#8217;', '&#39;', $content);

return $content;
}
add_filter('the_content', 'removesmartquotes');
add_filter('comment_text', 'removesmartquotes');

More reference

code snippets which is most useful in functions.php, wordpress
code snippets which is most useful in functions.php, wordpress

In wordpress – wp-includes/default-filters.php file, we have following list of filters which we can override.

/ Display filters
//add_filter('the_title', 'wptexturize');
add_filter('the_title', 'convert_chars');
add_filter('the_title', 'trim');
 
//add_filter('the_content', 'wptexturize');
add_filter('the_content', 'convert_smilies');
add_filter('the_content', 'convert_chars');
add_filter('the_content', 'wpautop');
add_filter('the_content', 'prepend_attachment');
 
//add_filter('the_excerpt', 'wptexturize');
add_filter('the_excerpt', 'convert_smilies');
add_filter('the_excerpt', 'convert_chars');
add_filter('the_excerpt', 'wpautop');
add_filter('get_the_excerpt', 'wp_trim_excerpt');
 
//add_filter('comment_text', 'wptexturize');
add_filter('comment_text', 'convert_chars');
add_filter('comment_text', 'make_clickable', 9);
add_filter('comment_text', 'force_balance_tags', 25);
add_filter('comment_text', 'convert_smilies', 20);
add_filter('comment_text', 'wpautop', 30);
 
add_filter('comment_excerpt', 'convert_chars');
 
//add_filter('list_cats', 'wptexturize');
//add_filter('single_post_title', 'wptexturize');

 

 

How to exclude images from wordpress post

In one of our project, we got the requirement of exclude images from wordpress post while showing post. We have written code for excluding the image from Post.

How to exclude images from wordpress post

you can use following code in functions.php file or you can use in single.php file. These files you can find in wordpress theme folder.

For changing the code you can use the wordpress admin -> editor section.

Above line I added in showing post without image.


<?php
$FormatedContent = content_with_formatting();
$content = the_content();
$postWithoutImage = preg_replace('/<img[^>]+./’,'' $FormatedContent);
echo $postWithoutImage;
?>

In above code we are checking the image tag and replacing with none.

If you want to find all images from post then Use following command.

preg_match_all('/<img[^>]+>/i',YOUR_text, $result);

You need to add following function in your function.php file(Theme files).

function content_with_formatting($more_link_text = ‘(more…)’, $stripteaser = 0, $more_file = ”)
{
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters(‘the_content’, $content);
$content = str_replace(‘]]>’, ‘]]>’, $content);
return $content;
}

If you want to Hide all images using CSS then use following code

img{
display:none;
}

Just put above code in your style.css file.

Fetch the wordpress post paragraph number wise

In this article we given code for Fetch the wordpress post paragraph number wise. created One function for fetching the wordpress post as per p tag number.

Fetch the wordpress post paragraph number wise

# You can Use this function for showing

function paragraph_show($paragraph_number, $post_content){
$show_after_paragraph_tag = 1;
$paragraph_number= $paragraph_number - 1;
//echo $paragraph_number;
$content = apply_filters('the_content', $post_content);

if(substr_count($content, '

') > $show_after_paragraph_tag)
//echo substr_count($content, '

');

{
$contents = explode("

", $content);
$p_count = 0;
foreach($contents as $content)
{
//echo $p_count;
if($paragraph_number == $p_count){
echo $content;
}

$p_count++;
}
}
}

We can use this function like this.

In while loop you can use or paste following code

#This will show the first paragraph of post.
post_content);

Image upload issue in wordpress with nginx

Nginx server is used by wordpress itself. We solved Image upload issue in wordpress with nginx. you can use following code.

Image upload issue in wordpress with nginx

Please Use the following code:


location ~ ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
root /usr/share/nginx/html/wordpressmu;
rewrite ^/.*(/wp-admin/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^/.*(/wp-includes/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^/.*(/wp-content/themes/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^/.*(/wp-content/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ /wordpress/wp-content/blogs.php?file=$1 last;

expires 10d;
break;
}

Nginx rule with image fix for multiple wordpress instance

I solved the issue with Wordprss and Images. If you want to host or install two instances on one domain in that senorio you can use following code. we given code for Nginx rule with image fix for multiple wordpress instance. you should use our code for fixing

Nginx rule with image fix for multiple wordpress instance

Please Use the following code;

location ~ ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
#images for wordpress instance one
if ($request_uri ~* /wordpress) {
set $set_root /usr/share/nginx/html/wordpress1;
}
#images for wordpress instance two
if ($request_uri ~* /moms) {
set $set_root /usr/share/nginx/html/wordpress2;
}

root $set_root;
rewrite ^/.*(/wp-admin/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^/.*(/wp-includes/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^/.*(/wp-content/themes/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^/.*(/wp-content/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last; expires 10d;
break;
}

Force remove the rpm from linux box

I installed the Mysql-cluster on fedora11 box.
When I tried the wordpress local setup on by box I got following error.
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.”

I used the noraml command for uninstalling the rpm package.
#rpm -e PACKAGE_NAME
I tried so many things but failed. Nothing is removed. Then I tried this command. I still got following result.

#yum list Mysql*.*
Installed Packages
MySQL-Cluster-gpl-debuginfo.i386 7.0.8a-0.rhel5 installed
MySQL-Cluster-gpl-extra.i386 7.0.8a-0.rhel5 installed
MySQL-Cluster-gpl-management.i386 7.0.8a-0.rhel5 installed
MySQL-Cluster-gpl-server.i386 7.0.8a-0.rhel5 installed
MySQL-Cluster-gpl-shared.i386 7.0.8a-0.rhel5 installed
MySQL-Cluster-gpl-storage.i386 7.0.8a-0.rhel5 installed
MySQL-Cluster-gpl-tools.i386

I tried the following commands…
#yum remove MySQL-Cluster-gpl-shared
This really worked…Yes this is final solution.

[root@localhost siwan]# yum install mysql mysql-server php-mysql mysql-common mysql-libs

[root@localhost siwan]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain for ServerName

This will solved your problem. Following links I found usefull:

http://www.rikers.org/rpmbook/node18.html
http://www.rikers.org/rpmbook/node20.html
http://www.rikers.org/rpmbook/node19.html

How to use Custom Page as Homepage in WordPress

wordpress tutorial, How to use Custom Page as Homepage in WordPress. Here we given full step by step explanation about using custom template.

This is one of the most wanted hacks that users want to know how to accomplish. First you need to learn how to create a custom page. You will need to duplicate your page.php or create a wordpress.php file and add the following code at the very top:

How to use Custom Page as Homepage in WordPress

wordpressapi */ ?>

How to use Custom Page as Homepage in WordPress
How to use Custom Page as Homepage in WordPress

You can change the template name. Change any styling, that you want in that page. Go to your WordPress admin panel and create a new page and select this template(wordpressapi).

custompagetemplate

Select your page to be the homepage as per your choice. Now you have yourself a Custom Home Page.

Have fun!