‘WordPress Hack’ Category

Paging and Custom WordPress Loops

94
responses
by
on
April 19th, 2008
in
HOW-TO, WordPress FAQs, WordPress Hack

Last week I published two articles using custom loops. The first was about how to create a custom loop. The second was how to retrieve posts based on custom fields. In both articles, several readers commented that they would like to see paging and have it explained. I’d like to thank Aaron Harun from Anthology of Ideas for supplying the code used in this post. Paging, and why it doesn’t work with WP_Query The paging magic happens in a file called ‘link-template.php‘ in the ‘wp-includes‘ folder. Most themes have basic paging built in, with the help of two functions: next_posts_link and previous_posts_link. These functions, as well as several others, make use of a global variable called $wp_query. This variable is actually an instance of the WP_Query object. However, when we create our own instantiation of WP_Query, we don’t have this global variable $wp_query, which is why paging will not work. […]

[Continue Reading...]

How to Only Retrieve Posts With Custom Fields

32
responses

One question I come across a lot regarding custom fields is how to only retrieve posts based on a custom field. For example, if a post has a custom field of “MyData”, someone might want to only retrieve that particular post. The WordPress Codex has a technique for retrieving posts based on custom fields, which consists of writing your own query and going through the results. The technique in the Codex is good, but I’ve found a re-usable way one can retrieve only posts with certain custom fields. The technique I use makes use of two custom functions placed in a theme’s “functions.php” and a custom WordPress Loop. Let’s get started — The “functions.php” file First, let’s place the two custom functions in the “functions.php” file. This file should be in your theme directory, but if it isn’t there, you can create one using any text editor. Here are the […]

[Continue Reading...]

Define Your Own WordPress Loop Using WP_Query

78
responses
by
on
April 13th, 2008
in
HOW-TO, WordPress FAQs, WordPress Hack

We all know what the WordPress Loop is right? If not, there are many great tutorials around the web that explain the WordPress Loop. One of the easiest ways to navigate and manipulate the loop is to use the function called query_posts. Nathan Rice calls it a WordPress developers best friend. When you use query_posts, however, you risk the following: Potential to interfere with plugins which make use of the Loop. Potential to invalidate WordPress conditional tags. Having to deal with resetting, rewinding, offsetting… I say skip query_posts. In a way you’ll still be using it, but the better (and sometimes easier) technique is to instantiate your own WP_Query object and create your own loop. Creating Your Own Loop With WP_Query The first step is to instantiate your own variable using the WP_Query class. What we’ll be doing in this example is creating a common feature on blogs, which is […]

[Continue Reading...]

Shortcode Generator

4
responses

Julien of Webinventif has created a shortcode generator for WordPress. Shortcode is like BBcode in that it provides the ability to use shortcuts to execute a block of code, rather than having to write out the block of code time and time again. Julien has made use of the new API calls within WordPress and with his shortcode generator, makes it easy as 1,2,3 to create your own custom shortcode. Although everything has been written in French, this generator looks promising. If anyone could translate this generator into English, I think there would be many WordPresser’s who would be grateful. Here is a screencast showcasing the generator in action. Shortcode generator from WebInventif.fr on Vimeo

[Continue Reading...]

Managing Trackbacks and Pingbacks in Your WordPress Theme

43
responses

With all of the recent discussion regarding trackbacks and pingbacks on Weblog Tools Collection, I thought I’d mention several ways one can deal with trackbacks and pingbacks in the context of a WordPress theme. The topics I will be covering in this article are on separating trackbacks/pingbacks from regular comments, and also how to remove trackbacks and pingbacks from a WordPress theme completely. Separating Trackbacks/Pingbacks From Comments I know what you’re thinking: numerous posts have already been written on how to separate trackbacks from comments. But what I present here is an actual separation using the “functions.php” feature for WordPress themes along with the regular “comments.php“. Both should be located in your theme directory. Figure 1: Theme Directory Setup Modifying the functions.php File The “functions.php” file is a lifesaver for any theme developer or tinkerer wishing to add custom code or functions to themes. The code in the “functions.php” file […]

[Continue Reading...]

WordPress as a Membership Directory

23
responses

WordPress as a Membership Directory: After the recent tutorial on setting up WordPress as a Contact Manager, Chris Cagle has written up a tutorial on WP Designer on how to use WordPress as a Membership Directory. He has setup a Membership Directory for Pittsburgh Designers and uses his experience from that project to outline the steps, plugins and code required to set this up for yourself. Beside the annoying CSS bug that puts a text box in the middle of every page, the setup looks nice, highly versatile and very useful for both designers (in this case) and future clients. I really like the Members Directory and the ability to display detailed contact information and portfolio of every designer. Even the signup is automated (and modified to suit the need) and relatively painless. I am curious to know what they plan to do about possible spammers posing as designers, but […]

[Continue Reading...]

WordPress as a Contact Manager

30
responses

WP Contact Manager: The versatility of WordPress continues to amaze me. Design Canopy has released a theme/set of instructions for WordPress that would allow you to run a WordPress install as a taggable, searchable contact manager that can be made into a Members Only system and display related contacts. Now mind you, it is not a stand alone theme, needs extra plugins to be downloaded and installed and they outline detailed instructions on how to set it up. However, the setup looks relatively easy and the results are definitely pretty cool. I would have liked to see a Prologue like custom posting interface for logged in users but that could be an easy add on or plugin once the thing is set up.

[Continue Reading...]

Mobile Phone optimized WordPress

17
responses
by
on
January 24th, 2008
in
WordPress Hack, WordPress Plugins

Mobile Phone Optimized WordPress: Thanks to a tip from Amit, I found a quick and painless way to optimize a WordPress blog (or any blog with a feed for that matter) for use with a mobile phone. The trick is to use Google’s excellent mobile news readers to display your blog. The resulting content is not only lightning fast, it is also well formatted and relatively easy to navigate. To see for yourself, craft the following URI in your browser. http://www.google.com/reader/m/view/feed/[Your Feed URI] This is the optimized mobile version of Weblog Tools Collection. Once you have the feed, just create a link on your blog for readers to follow and/or bookmark. Of note is the excellent WordPress Mobile plugin from Alex for those who like a one stop shop.

[Continue Reading...]

WordPress Post Thumbnails

20
responses
by
on
November 24th, 2007
in
Cool Scripts, LinkyLoo, WordPress Hack

Giving each WordPress post a thumbnail, and display the thumbnail on the home page: Interesting tutorial on creating thumbnails for each post on your blog and using Custom Fields to add and display them on your front page. A word of warning: the process is hand crafted and labor intensive. Think of them as SnapShots for your WordPress posts, hosted on your own blog. I think this could be a very cool plugin that automagically builds thumbnails for your posts and stores them on your blog. Then a custom function that behaves like “recent posts” could display thumbnails of your posts on the front page. I see this feature being really useful for those who post a lot of multimedia such as videos and pictures. Thanks HackWordPress [EDIT] Also, check out another Custom Fields thumbnail tutorial.

[Continue Reading...]



Obviously Powered by WordPress. © 2003-2013

css.php