Pages

Showing posts with label Wordpress. Show all posts
Showing posts with label Wordpress. Show all posts

Sunday, May 8, 2011

Wordpress HTTP Error on Image Upload after Crunching - Fixed


Hi Guys, In Wordpress while uploading a file sometime you may encounter an HTTP Error while crunching file.
Usually this error can be resolved by adding a line of code in htaccess file.

.htaccess file
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress



Edit your htaccess file and add the last line of code.
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

AddType x-mapp-php5 .php .php4

Your htaccess file will look like above. Upload it to your wordpress site root.

Thursday, May 5, 2011

Trick for displaying Number of Comments in your WordPress Blog


Place below code where you want to display your comment count:
<?php
$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
if (0 < $numcomms) $numcomms = number_format($numcomms);
echo "There's ".$numcomms." total comments on my blog";
?>


Display Most Popular Posts in WordPress


Place below code where you want to display your Most Popular Posts:
<h2>Popular Posts</h2>
<ul>

<?php $result = $wpdb->get_results("SELECT
comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count
DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
<?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
<?php } } ?>
</ul>
Just change the 5 in line 3 to change the number of displayed popular posts. That’s it.

Adding Rich Text Editor to Wordpress Sidebar Widget


Now i'm telling you on how to add a rich text editor inside a Text/HTML widget in a Wordpress Admin Panel - Widget Area. Here we are using CKE Editor as the Rich Text Editor
Steps
1. Download CKE Editor 
2. Extract the cke editor files to your 'wp-content\themes' folder
3. Go to admin header page \wp-admin\admin-header.php file and add the javascript reference in the head

4. Go to admin footer page. Add the below script above
< script type="text/javascript">
    CKEDITOR.replace( 'widget-text-4-text',
    {
        toolbar :
        [
            ['Bold', 'Italic','Underline','Strike', '-', 'NumberedList', 'BulletedList','Blockquote', '-', 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Undo','Redo','Link','Unlink','RemoveFormat','TextColor','Image']
        ]
        

    });
Replace 'widget-text-4-text' with your widget text area id. View the below image to know how to get your widget text area id.
5. Done
6. Go to wp-admin page -> Widgets -> Add Text/HTML widget to sidebar.
7. Voila.. Now you can see the RTE in action.

PHPThumb Error Deprecated: Function eregi() phpthumb.class.php - Fix


While using phpthumb for image resizing functions there may arise some issues if the source image is not working or the source image URL is dead.
The usual error found is "Deprecated: Function ereg_replace() is deprecated in phpthumb.class.php on line 976."

To fix this replace the function with

"if (preg_match('#^'.preg_quote($this->config_document_root).'#', $filename)) {"


Wordpress HTTP Error on Image Upload after Crunching - Fixed


Hi Folks, In Wordpress while uploading a file sometime you may encounter an HTTP Error while crunching file.
Usually this error can be resolved by adding a line of code in htaccess file.

.htaccess file
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress



Edit your htaccess file and add the last line of code.
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

AddType x-mapp-php5 .php .php4


Your htaccess file will look like above. Upload it to your wordpress site root.
Try It !! Best of Luck...