| CARVIEW |
Blog of Leonid Mamchenkov: Technology / WordPress
Thank you for being the greatest audience ever.
]]>]]>The last change means that the next time you login the value stored in the database will change – this means that if you do upgrade passed this point reverting back to an old version will invalidate all users passwords and they will need reseting. Therefore it is a good idea to backup up your users table before updating to the latest trunk.
(Thanks to Benedict Eastaugh over at wp-hackers mailing list for the above link)
]]>This tip has been written by Karthik Kastury from dailyApps.net. dailyApps showcases the best of the Apps for different platforms and is a must read for all you software junkies out there. You can also find a host of tips to improve your productivity with review of various services and apps.
If you are a long time WordPress user like me, you surely know the obvious limitations that the WordPress backend has. There are far too many distractions in the Compose Section where you write the posts. Presence of Controls that you never use could become a nightmare to manage so it would be best if you would just remove them and use a stripped down version of the Compose Screen to manage your workflow better.
- Get Rid of the Clutter
As I mentioned before there are far too many items in the compose screen that I normally don’t use. There is stuff like Password Protection, Excerpt, Custom Fields, Discussion Options, Bookmarklets, Author controls etc. which I am sure majority of WordPress Users don’t really use. So if you are one of them go ahead and add Clutter Free to your ever growing list of WordPress plugins.
Once you have activated Clutter Free go the Users Sections and select all the options that you need. Save the settings and “Boom!” as Steve Jobs would say, your Compose screen now loads a tad faster.
- Disable the Rich Text Editor
When it comes to the Rich Text Editor things are definitely easy for the average to publish a new post. But in case you are a power user like me then you would want to Disable the Rich Text Editor Screen that has a few annoyances, such as being slow and standing in the way of embedding code provided by Youtube and other services.
I would put my money on the Simple Text Editor that is extremely powerful in terms of what it can do. To disable the Rich Text Editor follow these steps. Go to the Users Section in your admin. Scroll to the bottom and uncheck the option that Says “Use the visual rich editor when writing”. The only Downside is that you will have to learn some basic HTML before you can use the Rich Text Editor.
- Make QuickTags Smarter
If you are long time WordPress user you will know how useful Quicktags really are (Quicktags are those buttons with tags at the top of the editor). Just about anything is possible with Quicktags. The default WordPress install comes with a few quick tags like <strong>, <li>, <ul> etc. But you might want to add a few more tags to this list so that you don’t have to type them over and over again while you are writing your post. I have some more tags in my Write screen like <span> which I regularly use.
If all the talk above sounded a little too geekish for you. Here is the simplified version of what you have to do. Just download the WP-AddQuickTag plugin and install it. Select Add Quicktags under the Options menu and add all the tags that you wish to include. Note that you need to have Rich Text Editor disabled to make Quicktags work for you.
- Install Greasemonkey
If you are a Firefox User you definately should install Greasemonkey. There are many scripts that can improve your workflow. One of the scripts that I am using is Akismet Auntie Spam which changes the skin of the Akismet spambox page for WordPress admins and allows to download all spam at once, compress spam to make it more scanable and completely compresses obvious spam. Turns checking spam into a 10 minute per week activity.
- Install WP-Admin Tiger 3.0
The default layout of the WordPress Admin can be confusing at times. It shows all signs of being extremely cluttered. You have to click through a maze of buttons to do something, and the most important thing surely is that it is not really good to look at. In case you are one of those who have got bored of the default layout for WordPress Admin then its time for you to download WP-Admin Tiger 3 that completely changes the look and feel of the WordPress admin.
]]>If you like this post please consider subscribing to the dailyApps feed. You will find dailyApps an enjoyable read. And yeah make sure you tell me if these tips have helped you or not..
This new feature required a few changes in the WordPress database scheme. Gladly, Ryan Boren has posted the description of changes in the database structure.
]]>If this type of documentation appeals to you, Lorelle has a whole bunch of cheat sheets for all things related to WordPress development – HTML, CSS, PHP, SQL, etc.
]]>In this post we’ll see which filenames WordPress recognizes in the theme directory, and how it knows which posts to show to the visitor based on where the visitor is.
Hopefully by now you’ve looked through the source code of a few WordPress themes. While each and every theme is unique, there are parts which are common among all themes. One of the common things that you probably noticed, is how themes are separated into files – index.php, category.php, search.php, single.php, home.php, etc. Practically any theme out there use some combination of files with common names. Those themes that don’t use any files or use just a few, usually apply a different technique – they have conditional statements like is_home() or is_page() within index.php.
The questions you probably asked yourself at some point were – “Which filenames does WordPress recognize?” and “Which other conditions similar to is_home() or is_page() can I use?”. And if you have a really inquiring mind, you probably also asked “What happens if I use different, non-standard filenames?” and “How does WordPress knows that a visitor is looking at search results and not archives?”.
The answers to all those questions lie in WordPress template hierarchy. While it looks like yet another Codex page, don’t be mislead. This particular page is priceless. It’s The Holy Grail of WordPress theming. Mostly, because of two things – a diagram and a link to Conditional Tags page. The diagram alone is so precious that I’ll have a copy of it here, just in case it disappears from Codex.
This diagram, just in one little drawing, tells us most of what we need to know about organization of WordPress themes. Let’s take a better look.
On the left side, we have the visitor, coming to the WordPress web site. The visitor can navigate to a number of pages – front page, full post, full page, category, author page, date-based archive, search results, and even a non-existing page. WordPress knows where the visitor is based on the URL which is used to get there. You can see from the diagram that WordPress understands both fancy URLs as well as URLs with parameters.
For each of those location, our theme can have a separate template file. WordPress checks if that file exists, and uses it if it does. Otherwise it falls back on to the next template file in the hierarchy, and checks for its existence, and so on, and so forth, until either a file is found or an index.php is reached.
So, from the diagram, if you want to separate the code for displaying the front page from everything else, use home.php . Or use is_home() conditional tag in index.php . Use single.php or is_single() condition in the index.php for single posts. And so on.
As you can see (from the diagram again), there is a very flexible way of controlling what happens when a particular post, page, or category is displayed. For example, you can have different logic and presentation for category with ID 5 from the one with ID 6.
Do we have to separate our theme into files? No. We can do everything with just conditional tags from within our index.php. But the truth is that if done this way, our index.php can often get rather large and complex, with a lot of conditions, and difficult to maintain. To make things simpler we probably should use multiple smaller files.
While we are on the topic of filenames, I think it’s good to look also at Include Tags. Include tags cover a few more filenames, which are recognized by WordPress, but not documented in template hierarchy. header.php, footer.php, sidebar.php and comments.php can be easily included from your other theme files by using calls to get_header(), get_footer(), get_sidebar(), and comments_template() respectively. Also, note that there is some magic about the comments_template() call:
This tag includes the file comments.php from your current theme’s directory. If that file is not found, it will instead include wp-content/themes/default/comments.php. To display comments on the main index or archive pages, you’ll need to set the $withcomments variable to “1” before calling this tag.
Last time, when we talking about The Loop, we mentioned that there was some magic about how WordPress knows which posts to show. I hope now you see how that magic is done. The core of The Loop is the have_posts() function call. Because WordPress recognizes the current visitor location from the URL, have_posts() knows which posts it should get – the ones in archives, the ones in the category, the ones on the front page, or the ones in the search results.
Now we know how theme part of WordPress works. In the next post we’ll see how we can control and modify WordPress behavior using The Query.
]]>The Loop is perhaps the most important thing there is to understand in WordPress theme building. It is the heart, the soul and the skeleton of any WordPress theme. It’s been fairly well documented at Codex – see pages “The Loop” and “The Loop in Action” – but no WordPress theme building series could be complete without yet another attempt of making it easier to understand, so here we go…
Let’s try and make it as simple as possible – The Loop is all about posts and pages.
Think about any WordPress web site out there. Now separate that web site into logical parts – front page, single post, single page, archives, category, search results, etc. Any of those parts does one of the things below:
- display single post or page (either a title, link, excerpt, or full body content)
- display a list of posts or pages (archives pages, category pages, search results, etc)
- display several lists of posts and pages (complex front pages with posts from several categories displayed separately)
If you know how to control The Loop, you know how to do any of the above. Now let’s see how it works, in case you weren’t born with The Loop Controlling Super-Powers.
Navigate your file manager to the themes directory of your WordPress installation, and look through any theme that you have available. One common thing between all themes that you probably won’t notice from the first glance, looks something like this:

It is somewhat difficult to notice, because the lines above are usually surrounded by a lot of theme specific XHTML and PHP. Let’s clean those lines up a bit, so that they make more sense:

Better? Here is how it goes. A check is done for if there are any posts (or pages that is) to be displayed on the current page. If there are any, then a while loop is started and each post is loaded one by one (using the_post() function call). This is a rather simple piece of code, which does a lot on the background, and makes our lives, as theme developers, a lot easier.
First of all, The Loop is smart enough to understand where we are – front page, category, archives, or search results. That means that you’ll use exactly the same code to lists posts no matter where you are. (In our next post for this series, we’ll see how WordPress identifies different locations a visitor can come to, and how we can control what is displayed.)
Secondly, The Loop gets all those relevant posts, taking into consideration the limits which you’ve set in the Options -> Reading -> Blog Pages -> Show at most X posts.
Thirdly, it provides us with a bunch of useful functions for displaying particular parts of posts – the_ID(), the_title(), the_guid(), the_content(), the_excerpt(), etc. Here is a simple example of The Loop in action:

The above snippet will look for posts, and if any are found, will show a title and full content of each, linking title to the full post page. If no posts were found, the truth will be told.
Which functions are available from within The Loop? Now that’s a touch question. There are quite a few, but one has to dig through WordPress source code to find them all. Looking through theme files is an alternative, but a rather limited one – most themes use the same stuff.
If you are prepared to look through the source code, start in wp-includes/ directory and given priority to files named something-template.php (wp-includes/post-template.php is a good place to start). These usually provide functions for templates, and that’s exactly what you need. Also, while looking through those functions, note that some even accept parameters.
Now I’ll give you some time to play with your loop. Make it beautiful. Make it useful. Learn it inside out. In the next post we’ll see how WordPress knows which posts to fetch (hint: template hierarchy), and, once we know, we’ll see if there is any way for us to control that behavior (hint: the query).
]]>