Tutorial Video for “PHP Function for Fetching RSS Feed and Outputting Feed Items as HTML”

After the post A PHP Function for Fetching RSS Feed and Outputing Feed Items as HTML was originally published, there are some updates such as adding a simple RSS feed caching mechanism and supporting scanning content parts of the feed items for images. Recently, Webucator makes a great tutorial video on introducing the RSS to HTML PHP function. Here is the video that teaches how to use the PHP function. » Read more

Speeding Up WordPress with APC Object Cache and WP Super Cache

WordPress can be very fast after some (small) effort on performance optimization with the help from its plenty of plugins. Two of the directions are using cache to cut down the number of database queries and optimizing PHP’s performance with opcode cache. In this post, we introduce how to speed up WordPress with APC object cache and page cache with the two plugins “APC Object Cache Backed” and “WP Super Cache”. » Read more

PHP Photo Gallery Scripts Requiring No Database

It is nice to set up some photo gallery on the web and share with friends and family. Some online services are good and convenient. But if you want to host it on your own domain and control them by yourself, there are also many scripts available. Usually, we want the script simple to use and easy to set up without requiring any database. » Read more

Controlling Display of WordPress Widget with PHP Code

I am always wondering how to display different Widgets in WordPress depending on the page/post/category etc. I ever tried some plugins that is for specific purpose. However, they are not flexible enough for all my needs. For example, I want a widget that contains AdSense ad not display on certain posts that I selected and marked by the post meta, which is not easy to control with some plugins that only support limited integrated controlling options. » Read more

Get the Number of All Posts in WordPress

Use the wp_count_posts() function to get the posts count. The code: <?php $count_posts = wp_count_posts(); $count_pages = wp_count_posts('page'); echo "<li><a href=" . get_option('home') . ">"; echo $count_posts->publish . " Posts, " . $count_pages->publish . " Pages"; echo "</a></li>" ?>        » Read more

How to Read File into String in PHP

Read content of a file to string (in this example, we echo it): // Get text from file function get_text($text_filename) { if ($text_filename != "") { $text = ""; $text_file = fopen($text_filename, "r"); while (!feof($text_file)) { $text = $text . fgets($text_file, 4096); } fclose($text_file); if ( $text != "" ) { echo $text; } } }       » Read more

Speeding Up the Site by Using PHP GZIP Compression

Compression is a simple way to speed up the site. PHP’s gzip compression is excellent. And using it is very convenient: Simply put these codes before any HTML content at the beginning of the PHP script: <?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?> In WordPress, the suitable position for these codes is the beginning of the header.php file of the theme. » Read more

WordPress Theme: ZM Theme

About ZM Theme ZM Theme is a simple and light-weight theme for WordPress. ZM Theme provides a green style, bright view and fast rendering experience to the users. ZM Theme passes W3C XHTML 1.0 and W3C CSS level 3 validation. This theme works well on WordPress 2.9.x. ZM Theme is originally designed for this blog based on Green Park 2. After changing a lot of the design and the style and making it pass XHTML 1.0 and CSS level 3 validation, I decided to publish it. » Read more

PHP Redirect with HTTP 301

The htaccess method can be found in How to Redirect Old Domain to New Domain Using htaccess Redirect. This is the method that use php to generate the HTTP 301 Redirect. There are a lot of benefits of using HTTP 301 Redirect. These benefits can be found in the htaccess method post. The header(“HTTP/1.1 301”) part must be used before the location part, otherwise PHP will automatically set the status code to HTTP/1.1 302 Found. » Read more

Use noindex Meta Tag in WordPress to Prevent Search Engine Indexing Categories, Tags and Archives

WordPress has the content duplication problem which may confuse search engines. Duplicate content won’t hurt you, unless it is spammy or keyword stuffing, as said by Matt Cutts, and Google may just ignore the duplicate content. However, instead of letting the search engines decide which pages of the duplicate ones are important, we may only want the search engine to index the posts and pages instead of categories, tags or archives. » Read more

Put the Categories, Archives and All Posts into Pages

I prefer putting pages that contains all the categories, archives and even all the posts in one page to putting these links in the side bar. Actually, most of time it needn’t to stay on every pages. And if it is in the side bar, the search engine will see these links in every page and think it is very important while it is not so important. » Read more

Change WordPress’s Excerpt Length

The default excerpt length of WordPress is 55 words. Some one like me may want to change the excerpt length. I like the have a smaller excerpt length for the homepage. WordPress provides a interface for changing the default excerpt length. The method is very simple and easy. Put these codes into the function.php file in the theme directory. I prefer 35 in my blog. » Read more