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>” ?>
Tag: PHP
How to Read File into String in PHP
Posted onRead 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
Posted onCompression 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
Read more
Friendly WordPress Navigation Using Page Numbers Instead of Next and Previous Links
Posted onThe navigation will be more user friendly with page numbers instead of next and previous links since users can navigate much quicker to the page they want to see especially when there are a lot of pages. It is also good method for SEO (Search Engine Optimization) because it creates a tighter inner link structure.
Read more
How to Redirect a Page with HTTP 301 in PHP
Posted onHTTP 301 Redirect is an SEO friendly way to redirect readers to a page’s new location. There are a lot of benefits of using HTTP 301 Redirect. These benefits can be found in the htaccess method post. htaccess or PHP can be both used for sending 301 redirects. The htaccess method can be found in
Read more
Put the Categories, Archives and All Posts into Pages
Posted onI 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
Read more
Change WordPress’s Excerpt Length
Posted onThe 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
Read more
Using noindex Meta Tag in WordPress to Prevent Search Engines Indexing Categories, Tags and Archives
Posted onWordPress may show “duplicate” content which may potentially confuse search engines. Duplicate content won’t hurt much, unless it is spam 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
Read more
Use Excerpt in Index, Category, Tag and Arhieve Pages for WordPress
Posted onBy default, all of the content of the post is shown in index, category, tag, archive and search pages. This is duplicate contents which may cause search engine penalty. The better way is using excerpt in index, category, tag and arhieve pages. By doing this the duplication can be avoided and the blog is optimized.
Read more
Gnome2 Style: Shiki Colors+Gnome Colors
Posted onThe Linux Gnome style that I like is Shiki-color + Gnome colors icon theme. It looks pretty and professional and it is fast. How to install them: Gtk engine: # yum install gtk-murrine-engine Icon theme: # yum install gnome-colors-icon-theme Theme: Dowload from here: http://gnome-look.org/content/show.php/Shiki-Colors?content=86717 Install it by Appearance Preference -> Install. Configuration: Appearance Preference ->
Read more
The WordPress Desktop Client – lekhonee
Posted onI find a desktop client for publishing to WordPress blogs – lekhonee[1]. I find it interesting and easy to use. This is the first post using it. The interface is simple, but it can provides most of the functions: * Writing post. * Select categories. * Add tags. * Load and Edit the old post.
Read more
Installing NVIDIA Driver in Fedora
Posted onUsing rpmfusion’s rpm packages to install NVIDIA driver in Fedora is introduced in this post. First, check the proper drivers for the card on [1]. 1. Add rpmfusion. Enable RPM Fusion repositories 2. Install the driver # yum install kmod-nvidia xorg-x11-drv-nvidia The reboot system. 3. Edit /etc/X11/xorg.conf # nvidia-xconfig The nouveau module conflicts with the
Read more
Reading List for Distributed Systems and Cloud Computing
Posted onUnderstanding the literature is usually the first step to do research, which is the same for systems research on cloud computing. A reading list may help a lot to those that just start in cloud computing research. Prof. Lin Gu, my PhD supervisor, compiled a reading list for system research on cloud computing. The reading
Read more