Shortcodes are designed to allow you to call certain plugin or built in theme functions within the post/page editor. This code snippet allows you to use shortcodes in a template file as well.
Need your single post views to be totally different depending on what category the post is in? You can do this easily by creating special single post files for each category as needed, and then replace the code in your single.php file with the following:
<?php
if (in_category('jobs')) {
include(TEMPLATEPATH . '/single1.php');
} elseif (in_categorye('News')) {
include(TEMPLATEPATH . '/single2.php');
} else {
include(TEMPLATEPATH . '/single3.php');
}
?>
Obviously if you only have one special category you won’t need the “elseif” statement in the middle.
Check the conditional tags reference in the Codex if you need to control the single post template by something other than category such as tag, post number, etc.
WordPress sets a cookie on a user’s computer that remains stored for 10 days after they visit a site. This means they will not have to re-enter their info every time they leave a comment, nor will they have to re-enter the password on password protected pages or posts. Sometimes, however, a site owner might want to require the password each time a visitor wants to view a certain page. Here’s how:
Check out wp-pass.php in your wordpress directory.
You’ll find a line like this:
setcookie(‘wp-postpass_’ . COOKIEHASH, $_POST['post_password'], time() + 2, COOKIEPATH);
The value after the “+” indicates the time in seconds, the cookie stays valid. In this example it is valid for 2 seconds, setting it to 7200 would be equivalent to 2 hours.
This, of course, is a trade off. If there is very active discussion on a site, users may become frustrated at having to re-enter their information each time they want to leave a comment. In this case, it might be better to find another solution for protecting information on a given page.
More »
This is a great tip for limiting the built in search functionality to search only the category you specify. The author provides the code for searching just a single category or searching only the children of a certain category.
I don’t know about you, but I’ve always been a little afraid to run queries directly on my WordPress database. This post goes through how to accomplish many tasks using queries. Sometimes the task of going post by post to make a change would take you 10 times as long as just running a simple query.
(I use the WP-DBManager plugin to manage database backups and optimization, and it has a panel where you can run queries on your database, so you wouldn’t even need to figure out how to get into PHP MyAdmin to run these queries.)
Search engine traffic is where you really make money on Adsense, so some blog owners choose to show ads only to visitors who come in through the search engines. This article explains how to accomplish that and to show alternate content to other visitors.
This post explains how to give the post author the ability to add Google Adsense (or any other content of course) into a post wherever they like by using a shortcode or just a certain text string using the str_replace() function. Very useful!
This is a helpful article about ways to automatically insert certain content in various areas of the post, such as before plugin output at the end of a post, or just after the “more” tag.
The original way to highlight author comments only works for one user ID for the whole site. This article explains how to highlight comments of authors on blogs that have multiple authors.
Ever wanted to display your subscriber counts from Feedburner, but didn’t want to use the “chicklet” they provide for that purpose? This PHP script will do the trick!