From Code Snippits

Expanding the Twitter Post Loading Concept to WordPress

I read a great tutorial over at NetTuts today that showed how to create a “Twitter-Like ‘load more'” button. It was grounded in WordPress, yet the author David Walsh wanted to keep it general so that anyone could integrate the functionality into their PHP code. He got his hands a bit dirty by accessing the WordPress database with raw MySQL commands and writing his own SQL which WordPress has worked hard to hide for most tasks. He left out the details of how to integrate this idea into WordPress using its built-in functionality. I’ve written a little code to bridge that gap. So, head over to the original tutorial and read up on the idea and then return here, download my PHP file as a replacement for David’s PHP/MySQL file. You can drop this file in your web root ¬†and load additional posts with it.

[download id=”1″]

Order Posts by Custom Key revisited

I’ve gotten quite a few questions about how to get this to work on a specific page, or only within a specific category. I actually had the same issue when building the script originally. The trick is that you can’t just use the conditional tags in the functions page. At that point, it’s already too late because the queries have already been run. Read more

Order Posts by a Custom Key

Just recently, we completed a website using WordPress for a realtor named Jon Dishon. One of his requests was to have his listing be ordered by price. Since we created his listings from simple posts with WordPresss’ Custom Keys, it was difficult for us to do this since Price is one of those keys. We wrote some special code to join the custom keys to the query being run for a specific page. Read more

WordPress 2.6.3 ships with a broken jQuery?

We’ve been adding a custom panel for the write post page for one of our clients and having the hardest time diagnosing the errors that we’ve been getting. It turns out that using the built-in jQuery library that ships with WordPress was the problem. We ended up having to download the library from the jQuery site and use some WordPress magic to make it use our library instead. Below is the code to use your own jQuery file. Put it in your theme’s functions.php (<your-blog-url>/wp-content/themes/<your-theme-name>/functions.php) page.

add_action("init", "install_jquery_scripts");
function install_jquery_scripts() {
	wp_register_script("jquery", "/path/to/your/jquery-1.2.6.min.js", array(), "1.2.6");

We had this issue with WordPress version 2.6.3 and just about any plugin we tried to run utilizing jQuery 1.2.6.