Top 25 PHP template engines

January 30, 2009

After searching the Internet for a good template engine, I have compiled the following list: Smarty Smarty is a template engine that compiles the templates into PHP scripts, then executes those scripts. Very fast, very flexible. Heyes Template Class A very easy to use, yet powerful and quick template engine that enables you to separate your page layout and design from your code. FastTemplate A simple variable interpolation template class that parses your templates for variables and spits out HTML with their values ShellPage A... [Read the full story]

Get wordpress parent page or post title

January 28, 2009

If you use pages and subpages or posts and parent posts on your WordPress blog, it should be a good idea to display parent page/post title while on a child page. Here’s a code to do that job easily. To achieve this recipe, simply edit your page.php file and paste the following code where you’d like your parent page title to be displayed: <?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?> That’s all. Also, this code should be some inspiration for creating breadcrumbs.  Read More →

Include external pages in WordPress navigation

January 28, 2009

Imagine that you’re running a blog, but also have an online shop, a forum and some static pages. Do you’d like to be able to include theses pages in WordPress navigation? If yes, just read on. The solution to this problem is fairly simple. As the wp_list_pages() function returns only <li>…</li> elements, we just have to add static links to our external pages, just as shown below: <ul> <?php wp_list_pages('title_li='); ?> <li><a href="forum.php">Forum</a></li> <li><a... [Read the full story]

Get words count of your wordpress post

January 26, 2009

How to get and display the word count of a wordpress post? The first thing to do is to create the function. Paste the following code on your functions.php file: function count_words($str){ $words = 0; $str = eregi_replace(" +", " ", $str); $array = explode(" ", $str); for($i=0;$i < count($array);$i++) { if (eregi("[0-9A-Za-zÀ-ÖØ-öø-ÿ]", $array[$i])) $words++; } return $words; } Then open your single.php file and paste the following code: Word count: <?php... [Read the full story]

Disable search engine indexing on a particular category

January 25, 2009

How to disable search engine indexing on a particular category? First get the ID of the category you’d like to be not indexed by search engines. In this exemple, I assume your category id is 18. Open your header.php file and paste the following code between the <head> and </head> tags: <?php if ( is_category('18') || in_category('18') ) { echo '<meta name="robots" content="noindex">'; } That’s all. With the above code, we made sure that no post from category with the ID 18 as well as category... [Read the full story]