Explore xNepali - xN Home | Movies & Fun | Nepali Blog | Photo Blog | Tools - | Unicode | Nepali Fonts | Preeti->Unicode
RSS feed

  • How to add photos/images in a WordPress post


    This is a beginner-level tutorial that shows how to insert an image in a WordPress blog.
    This tutorial covers only the most basic aspects of uploading and inserting an image.

    WordPress makes it easy and simple to upload images to the blog.

    Single image uploading and inserting:

    A short tutorial on uploading multiple images

    Incoming search terms:


  • Unicode text turned garbage and ?s in WordPress blog


    unicode-starts working Our blog – blog.xnepali.com is basically an English site. But, the movies posted there are in Nepali language – so we were posting the name of the movie in Nepali text.

    Recently for some unknown reason the cache plugin ‘Hyper Cache’ stopped working and I had to play around with the settings. After a couple of days I realize the text in the site have gone crazy.

    While searching the WordPress support I found out that the solution to the problem was the configuration file "wp-config.php". When I restored the back-up of the file, the unicode start to look fine.

    To troubleshot what might have happened, I removed some of the lines that were not present in the original files were and restored the new config file.

    The problem were the two lines in the config file:

    config-file

    Read the rest of this entry »

    Incoming search terms:


  • WordPress Feed XML Parsing Error, solved!


    UPDATE

    The solution mentioned originally did work for a few days and it went back to the same error. In desperate attempts, I removed everything and reinstalled WordPress. When that didn’t change anything, I moved everything from http://blog.xnepali.com to http://xnepali.com/movies. Well, that was the ultimate measure I could have done. But, to my unpleasant surprise, the RSS error was still there.

    It was so frustrating that I choose to ignore the error and continue as it was. Then, one fine day, I started trying to redo everything – removing all the plugins, changing themes and so on. I wasn’t hopeful but it was worth a try.

    Then I stumbled upon a suggestion that worked !!

    All I did was add 3 lines in two files – wp-includes/feed-rss2.php and wp-includes/feed-rss2-comments.php

    $out = ob_get_contents();
    $out = str_replace(array(“\n”, “\r”, “\t”, ” “), “”, $input);
    ob_end_clean();

    It is working now and I hope this is a bit more permanent solution.

    ***original post***

    When I got the following error in xnepali blog, I went searching for the solution in the internet.

    =======
    XML Parsing Error: XML or text declaration not at start of entity
    Location: http://blog.xnepali.com

    Line Number 2, Column 1:

    <?xml version=”1.0″ encoding=”UTF-8″?>
    ^
    =========listening

    feed-I was told to “remove any blank lines at the top or bottom.” To my surprise, almost every php files had a blank lines at the bottom. I don’t know what caused that. I tried removing the blank lines files containing “functions”, “RSS”, and “feed” in the name.

    After 1 hour of “hard work” I was till at the place I started. The error was still there. Then,I cam across a WordPress support thread. There was a person with problem similar to ours. The solution worked for me too.

    What worked for GaryWhite855 worked for me too:

    http://wejn.org/stuff/wejnswpwhitespacefix.php.html

    Looks like, the small php file removes whitespaces in php to solve the feed problem. I hope this information will be useful to those who face similar problem with the RSS feed of WordPress.

    Incoming search terms:


  • Add WordPress sidebar, header on Non-WordPress static pages


    A simple case, when I want to use all the dynamics of WordPress in sidebar, header, and footer but the main content is a separate page. I used a simple code in the following format.

    define('WP_USE_THEMES', false);
    require('../wp-blog-header.php');
    ?>
    -- head - title and so on ...--

    -- type your HTML in here --



    Now, the page is done but needs a bit polishing.


  • WordPress Rewrite rules – ballooning wp-options table


    When xNepali blog grew in size, the database load on the server was huge. We had to move to the Virtual Private Servers to deal with. But, to our surprise, we had to constantly play around with the memory to get the optimum result. There were a lot of times when database ‘max_allowed_packet’ bytes error were observed in error logs.

    To solve the database connection we tried adding another private server for database. But, it didn’t solve anything.

    In the blog there were about 400 pages. Somebody suggested that a lot of pages were not good for the server. We started migrating the pages to posts as post have better flexibility and more keyword options (like tags) than pages. Now, the number of pages are only about 200. But, the problem is still the same.

    I checked the rewrite-rules column in the wp-options table. It was almost 1mb in size.  There are
    if( is_array( $attachment_uris ) ) {
    foreach ($attachment_uris as $uri => $pagename) {
    $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
    $rewrite_rules = array_merge($rewrite_rules, $this->
    generate_rewrite_rules($page_structure, EP_PAGES, true, false));
    }
    }

    In addition, I added the following code in the function.php in the theme:


    function filter_rewrite_attachment($content) {
    if (!is_array($content))
    return $content;
    foreach ($content as $key => $val) {
    if (strpos($val, 'attachment') !== false)
    unset($content[$key]);
    }
    return $content;
    }
    add_filter('page_rewrite_rules', 'filter_rewrite_attachment');
    add_filter('post_rewrite_rules', 'filter_rewrite_attachment');

    The first code didn’t have much effect in the database size. The second code by Johan Eenfeldt from wp-hackers group did help reducing the table size. I need to wait for at least a day to see what performance enhancement or problem it will cause.

    Incoming search terms:


  • WordPress – database


    This post is for myself. I usually like to change database and forget the commands. So this is a reference sheet for me while dealing with my WordPress database.

    There usually are 11 default tables – with "wp_" prefix.

    wp_options is the one I usually deal with while changing the directory, website address and so on.

    Renaming tables

    RENAME TABLE old_posts TO wp_posts;

    Merging two tables (when I manually merge posts from two separate blogs. )

    CREATE TABLE wp_post_merged SELECT DISTINCT * FROM (SELECT * FROM wp_post_1 UNION ALL SELECT * FROM wp_post_2) sq;

    ….

    Incoming search terms:


  • Dreamhost VPS and WordPress Cache


    WordPress sites can handle large volume of traffic when WP-Cache or WP-SuperCache plug-in is used. The second plug-in, SuperCache, is actually the WP-Cache+ some improvements to help sites deal with caching. When these plug-ins are used, cache pages are usually served to the visitors instead of extracting contents from database for every single visitor.

    Well, that was not the case when I last used WP-SuperCache in the Dreamhost VPS. I don’t know much inside details but Dreamhosters need to find an alternative when WordPress Cache is concerned. Mine didn’t crash but there are reports of such things happening like this one.

    For my sites I found Hyper Cache does some justification in reducing the server load. There should be others but I haven’t tried them. Please comment your experience if you have experienced such problems.

    Incoming search terms:


  • Optimize WordPress for speed and resources


    With an experience of running a number of sites/blogs running on WordPress, I feel like sharing some of the issues I have experienced.

    WordPress if one of the simplest content management system (cms) available. It is easy to install, deploy, and modify when compared to other GPL cms like Joomla, Drupal etc. With a huge user base, there is a vast pool of themes and plug-ins (mostly free) to choose from.

    When I started using WordPress in late 2006 the sites I designed didn’t have much traffic. I had the flexibility to use any plug-in or theme on the sites. But as the traffic increased the server couldn’t stand it. Then I realized that it was not only the site traffic that determines how much server resource is required to run the site.

    The WordPress core in itself is light-weight but when it is coupled with add-ins and custom themes it can be very resources hungry. The worst resources hog I experienced was a Related Post plug-in.

    - Plug-ins can be heavy. Not all plugins are that bad but to be on a safe side; use less number of plug-ins
    - Templates with a lot of features and that comes with plugins can also be very heavy.
    - Keep homepage as light as possible with less javascript, images and scripts.
    - Keep WordPress updated and secured.
    - Spams – fight them. Nobody needs them and they are heavy on server too. Use plugins like Akismet, Defensio, reCAPTCHA etc.
    - Caching – When site traffic increases the database overload can occur. MySQL database limps trying to get the information needed to render the page. Best solution is to cache the pages so that database gets less load. There are various plug-ins like Wp-Cache, Wp-Super-Cache etc., to do the job.
    - Revision – Latest version of WordPress features ‘revision’. It is good to have history of every revision made on every post. But, it can be heavy on database too. There are plugins to limit the number of revision or delete revisions to make the database light-weight.