WordPress Wednesdays: Little WordPress Gems

Every once and awhile while looking through the WordPress documentation, I find little gems. Here are a few that I found particularly interesting:

  • wp_page_menu Easily create a menu with the home page appended onto the menu with a lot of parameters. Similar to the standard wp_list_pages, but with some different possibilities
  • the_search_query I have seen several ways to get this, but this is by far the easiest, quickest, and most secure.
  • wp_reset_query If you use conditional tags, you will end up going crazy at some point and then will realize this is needed. Note to self everyone.

Linkfest Thursday: September 10, 2009

This week – I feel like I really found some gems.

WordPress Wednesdays: Custom Taxonomies

I recently worked on a project where we needed something sort of like tagging, and sort of like categorizing – but neither really worked as there would be way too many exclude this and only show that stuff involved. I needed a way to classify certain content, have easy access to it, and display it in a manner that be effective and quick.

After exhausting all ideas – someone pointed me towards using “Custom Taxonomies” and it was a perfect fit.

What is a taxonomy? Simple – a way to group things. Why not use categories and or tags?

An example to better your understanding:
Right now – on this blog I use tags for my post themes (WordPress Wednesdays, etc). This is not ideal, because I am trying to group together posts by a particular theme, not necessarily by tags. Even though WordPress Wednesday could be seen as a key word – it is more a description or a classification of the post. What I plan to do in the next few days is to go back, create custom taxonomies for all my post themes and then use that for classification of posts instead of using tags. With this, I can then query them using query_posts or even make a tag cloud.

 'wordpress-wednesdays', 'showposts' =>; 10 ) );
 'post_theme', 'number' => 15 ) );

Still confused? Check out the links below. Once you start thinking about organizing information, I think it will make sense.

References:

WordPress Wednesdays: Get the Current Page

I was writing some functions that are used in the admin for my commercial WordPress theme: Lucidity and stumbled upon a great variable in WordPress: $pagenow. This variable will return the current page you are on and is great form admin functions – especially those that you want to only make available on certain pages.

To use this – just add it to your functions as a global variable, then you can use it to load in specific js/functions:

global $pagenow;
if (($pagenow == 'admin.php') && ($_GET['page'] == 'sdac_appearance')) {}

This proved to be very helpful when dealing with some finicky JS.

WordPress Wednesdays: Jappler Category/Tag Feeds

Perhaps you come to this site because you personally know me or like some of the WordPress hints I like, or like my CSS posts, or just like my personal rants (which seem to happen less…hmm I need to get on that!).

If you are only interested in some of my posts but not others, you can easily subscribe to just certain “subjects” very easily.

For example, lately I have been posting on a certain subject each day. (WordPress Wednesdays, etc). If you are only interested in reading those posts, subscribe to this RSS feed: http://www.jappler.com/blog/archive/tag/wordpress-wednesdays/feed. Perhaps you only want to read about things I post in the “Serenity Now” category. You can subscribe to http://www.jappler.com/blog/archive/category/this-and-that/serenity-now/feed. Do you see what I am doing? This logic will work on any tag or category. Find the tag URL (click on a tag) or find the category URL (click on a category in the sidebar) and then add “/feed” to the end of the URL – and there you go. A custom filtered Jappler.com feed.

Just another way WordPress makes it easy to interact with content!

WordPress Wednesdays: It is All About the Query

My last ten or so projects I have been working on all have a common theme: maximize WordPress’s ability to be a powerful CMS. Clients more and more are coming to me with the need to create a custom fields which they can store/query data throughout their site.

WordPress is completely customizable and because of this – it is easy to add custom fields to any post or page and then use the data put in them throughout the page.

Example: You have all your clients listed on your web site – and have created profile pages for them. Not only do you want to show their profile – you would really like to have a page template that shows all your client logos – and does so dynamically so that anytime you add a new client – their logo gets added to the mix automatically. The examples are endless and the solution is easy.

Step 1: Create a custom fields plugin (or use the generic custom fields) – personally I like to create a plugin so that I can completely customize and make adding content as easy as possible. If there is interest – I can cover how to create a plugin.

Step 2: Now that your data is stored – you can use it anywhere you want (in the loop, outside the loop). You can use something like:

ID, $key, true);?>

to display the data. (see Using Custom Fields for more information).

Step 3: Again – now that the data is stored – you can also query it so if you wanted to show all logos (as mentioned above) – you can do so by using WordPress’ query_posts to query and then display the data. (see Query Posts for more information).

Stuck? Interested? Let me know.

WordPress Wednesdays: Take Control of Missed Spam

Even with Akismet, and http:BL installed to stop spam – I still get the occasional spam comment. Until a few days ago, I simply got frustrated, went into the WordPress admin and then marked them as spam.

Spam Keywords

Then after thinking about this more, I remembered you could actually enter in your own text pattern that WordPress would use to mark comments as spam or block the comment completely. All the spam that was coming through – all had the same text in it (a series of question marks) so I added that into the “Comment BModeration” box to make sure that they were being caught appropriately – and after a week or so, I will then move that pattern down to “Comment Blacklist”. So – if you are like me and see some spam still slipping by your spam protection, take advantage of the two options to add in words, email addresses to block/send to moderation, under “Settings > Discussion”.

WordPress Wednesdays: The Power of Self Publishing

Having a blog or CMS that uses something like WordPress is a great way to easily publish content and is very easy for people who have no understanding of HTML, images or design but this power comes with a double edged sword.

On one hand, anyone can quickly upload images, video, and write text…even add some floating elements (picture on the left, picture on the right) without seeing any code. While this is great for most people, when something goes wrong (unclosed HTML tag) this can wreak all kinds of havoc on a site. I often get questions like “why is my entire blog in bold” or “what happened to my sidebar – it is now under the content. I even get people who look at my portfolio and email me about “you might want to fix this site because x is all messed up”.

While self publishing is great because it gives the writer all the power – it is also problematic because…it gives all the power to the writer. With this power – comes responsibility. If you want your business or personal image to be based on what people see on your web site – please take the time to learn some basics. Images look best at x size in this spot…this is how I bold something…etc.

As a web developer – I give my clients guidelines and do a lot of defensive programming to try and eliminate anything that I can foresee as being an issue – but please remember – while systems like WordPress easily allow you to publish your content – it also easily allows you to publish sloppy content.

There is a reason why most large companies have entire departments that control what goes out to the public with complicated review systems in place. So if you want to take advantage of something like WordPress, remember that you have all the control – both good and bad. If you see a site in my portfolio that looks skewed – know that the client would not allow me to hand that over to them like that. It is like that because they have complete control over the content. 😉

WordPress Wednesdays: All Posts in a Parent Category

The need to show all posts in a particular category or that category’s sub categories is very high. There are not too many projects out there that do not require a customized search, a menu, or a listing of some sort where the user wants to include all posts (or exclude) that belong to a parent category. Until recently – there was no real good way to do this. You either had to hard code category names or IDs in an array, or get really creative.

I recently started using the following function mentioned in the WordPress Codex that made this very easy: post_is_in_descendant_category().

By using that function – you can test to see if a post is in a particular category or even several subcategories deep of that category and then use that to easily show exactly what you want.

Examples and documentation for post_is_in_descendant_category: http://codex.wordpress.org/Template_Tags/in_category

Completed: One Life Goal and One 2009 Goal

Every Easter my family went to Myrtle Beach for a week to two weeks and we stayed in my mother’s cousin’s beach house. Alone, that was exciting, but what was mesmerizing was this thing called “cable”. Sure – cable was around when I was younger, but my parents thought channels 2-13 were enough for us. I would love going to Myrtle Beach and then watching this crazy comedian named Gallagher. Ever since I first saw his great Sledge-O-Matic – I decided I had to see him live…and I am finally going to next month. He is coming to the Chicagoland area and I am totally excited to see him in action.

Another goal of mine – has been to finally start releasing some WordPress plugins and I did that earlier this week by releasing SDAC Related Content – a highly configurable, cached plugin that allows you to show related posts by category at the end of your posts or pages that does not make any database changes (perfect for WordPress VIP). I have a few more plugins that will soon be released as well as some themes. I just need time 🙂