|
|
Want to know more about Packt's Article Network? Interested in contributing your article ideas? Please visit our FAQ for more information. See More BROWSE
All Titles WordPress Web Services SOA BPEL Web Graphics & Video Web Development RAW Portugues, Espanol, Italiano, French PHP/MySQL Oracle Open Source Networking & Telephony Moodle Microsoft & .NET Linux Servers jQuery Joomla! JBoss Java e-Learning e-Commerce Dynamics Drupal CRM Cookbook Content Management Beginner Guides Architecture and Analysis AJAX Future Titles Recently Published Titles In this two-part article by Jean Baptiste-Jung, we shall learn about managing and enhancing a multi-author blog. Are you running a multi-author blog, or at least hiring some guest bloggers? Indeed, the more authors you have, the more content you will have, along with a greater number of visits. In the beginning of 2009, many successful blogs such as, Smashing Magazine, Lifehacker, or Mashable, were powered by a team of bloggers. In this article, we are going to learn how to create, enhance, and get the most out of your multi-author WordPress blog. In this part, you will learn:
See More |
Enhancing User Experience with WordPress 2.7(Part 1)
As a blogger, I read loads of blog posts every day, on many different blogs. Very often, I'm scared to see how many blogs have a non user-friendly interface. How often does it happen that you can't click on the logo to go back to the blog homepage, or can't find what you're looking for by using the search engine? It is a well known fact that in blogging the content is king, but a nice, user friendly interface makes your blog look a lot more professional, and much easier to navigate. In this article, I'll show you what can be done for enhancing user experience and making your blog a better place. Replacing the Next and Previous links by a paginatorWhen a web site, or blog, publishes lots of articles on a single page, the list can quickly become very long and hard to read. To solve this problem, paginations were created. Pagination allows displaying 10 articles (for example) on a page. If the user wants, then he or she can go to the next page, or click on a page number to directly go to the related page. I definitely don't understand why WordPress still doesn't have a built-in pagination system. Instead, at the bottom of each page you'll find a Next link to go to the next page, and a Previous link to go back. This works fine when you're on page two and would like to go to page three, but what if you're on page one, and remember a very interesting article which was located on page eight? Are you going to browse page per page until you find your article? The answer is yes, because you don't have the choice. You can't jump from page one to page eight. In this recipe, I'll show you how to integrate a pagination plugin in your WordPress blog theme. One very good point of this recipe is that the plugin file is embedded in your theme, so if you're a theme designer, you can distribute a theme which has a built-in pagination system.
Getting readyTo execute this recipe you need to grab a copy of the WP-PageNavi plugin, which can be found at http://wordpress.org/extend/plugins/wp-pagenavi/. I have used version 2.40 of the Wp-PageNavi plugin in this example. Once you have downloaded it, unzip the zip file but don't install the plugin yet. How to do it
How it worksIn this recipe, you have discovered a very useful technique that I often use on my blogs, or in the themes that I distribute—the integration of a WordPress plugin into a theme. When the plugin is integrated into your theme as I have shown you in this example, there's no activation process needed. All of the work is done directly from the theme. The WP-PageNavi plugin itself works by using two values—the number of posts to be displayed per page and the first post to be displayed. Then, it executes the relevant query to WordPress database to get the posts. The pagination bar is calculated by using the total number of posts from your blog, and then dividing this value by the number of posts per page. One good point of this technique is that the plugin is integrated in your blog and you can redistribute the theme if you want. The end user will not have to install or configure anything. Highlighting searched text in search resultsI must admit that I'm not a big fan of the WordPress built-in search engine. One of its weakest features is the fact that searched text aren't highlighted in the results, so the visitor is unable to see the searched text in the context of your article. Getting readyLuckily, there's a nice hack using regular expressions to automatically highlight searched text in search results. This code has been created by Joost de Valk who blogs at www.yoast.com. How to do itThis useful code is definitely easy to use on your own blog:
How it worksThis code is using PHP regular expressions to find the searched terms in the text returned by WordPress. When an occurrence has been found, it is wrapped in a <strong> HTML element. Then, I simply used CSS to define a yellow background to this element.
WordPress 2.7 Cookbook
Using the CSS sliding doors technique within WordPressThe CSS "sliding doors" technique allows you to create sophisticated tabs for your menus. Sadly, WordPress doesn't allow you to use a <span> element in the wp_list_pages() and wp_list_categories() functions. Getting readyIn order to achieve this very cool menu, you first need to have a bit of knowledge about the CSS sliding doors technique, and the necessary images. If you need to know more about this technique, you should consider reading this article: http://www.alistapart.com/articles/slidingdoors/
If you don't already know this awesome technique here's a quick example to get you started: Let's start by building a typical navigation list: <ul id="nav"> If we use CSS to apply background images to our links in order to make this menu look prettier, we'll quickly come across a big problem. We must add a fixed width to the links otherwise, the image will be truncated for a very short link, or the link will overflow the image if its width is too long. That's why sliding doors are very useful. We just have to add a span element inside the link. Then, in our CSS, assign a different background image to both the span element and the link. <ul id="nav"> Our CSS should look like this: #nav a, #nav a:visited {Please note, as this is only an example, the preceding CSS isn't complete and only shows how to apply the sliding doors hack. How to do itI have read many WordPress users who modified their WordPress core files to achieve this technique. I have already talked about how modifying core files is a bad idea. Instead, let's use some regular expressions (as we did in the previous recipe!) to obtain the desired effect. Applying this hack to pages
You may have to style it a bit more in order to make it compatible with your blog's look and feel, but basically, you're done. Applying this hack to categoriesOf course, you can easily apply the previous hack to categories. Follow these simple steps:
How it worksAs you can see, applying this hack to categories or pages is almost the same. Basically, you just have to change the wp_list_categories() function for categories and wp_list_pages() for pages. To embed <span> elements in the list, this code uses the PHP preg_replace() function with the wp_list_categories() function as a second argument. In the wp_list_categories() function, the echo=0 parameter is specified, which means that the function doesn't print the result on screen but instead returns the result to be used in PHP.
SummaryIn this part we learnt a few methods for enhancing user experience and making your blog a better place. We saw how to use paginator, highlight searched text in search results, and using the CSS sliding doors technique within WordPress In the second part we will create a dropdown menu for your categories, add a breadcrumb to your theme, display related posts and tabs on your sidebar. If you have read this article you may be interested to view :
WordPress 2.7 Cookbook
About the AuthorJean-Baptiste Jung is a Web developer, Web designer, and blogger born in Paris, France and now living in Wallonia (French-speaking part of Belgium) with his wife and cat. Jean unearthed the World Wide Web in 1998 and started creating web sites three years later. In 2006, while working as a freelance Web developer for a well known French TV channel, Jean started to work with blogs and WordPress. A few months later, he created his first blog. He became immensely passionate about WordPress and launched a blog dedicated to WordPress hacks, http://www.wprecipes.com, which quickly managed to become one of the most popular WP-related web sites over the Internet. Meanwhile, Jean is also an author on some prestigious blogs, such as WpHacks, ProBlogDesign, and Smashing Magazine. Books from Packt
|
In this two-part article by Jean Baptiste-Jung, we shall learn how to enhance user experience and make your blog a better place for the visitors. In the first part we saw how to use paginator, highlight searched text in search results, and use the CSS sliding doors technique within WordPress. In this part, you will learn:
See More |
| ||||||||