You may recall my ancient post about customizing your custom post type permalinks. When I wrote that, I was still stumbling somewhat blindly through WordPress’s rewrite API. After hacking a little more with it, I think I finally understand what I’m doing enough to write a little more confidently. Continue reading
Solr and JSONP
Need to send an Ajax request to a Solr server that’s on a different domain? You will, of course, need to use JSONP instead of an ordinary JSON request, due to JavaScript’s cross-domain security restrictions. To get a properly padded response from Solr, add the json.wrf parameter to your query string, giving it the name of your callback function. In jQuery:
jQuery.ajax({
url: mySolrUrl,
data: myQueryParameters,
success: mySuccessCallback,
dataType: 'jsonp',
jsonp: 'json.wrf'
});
Of course, for this to work the Solr server you’re accessing needs to be publicly accessible, which probably isn’t ideal for security.
Excerpts for WordPress Pages
WordPress lets you create excerpts for Posts, but not for Pages. Generally, that makes good sense. If you need excerpts for pages, though, it’s pretty simple to add.
function my_init() {
add_post_type_support('page', array('excerpt'));
}
add_action('init', 'my_init');
That’s all there is to it. Works with WordPress 3.0+.
Update 2010-10-01: Hey, look, I made it into a plugin.
Downgrade PHP to 5.2 on Ubuntu 10.04
As of version 6.14, Drupal works with PHP 5.3, but many essential modules still issue warnings (usually due to passing expressions by reference). If your Ubuntu 10.04 (Lucid Lynx) server is running 5.3, this script will automate the downgrade to the latest 5.2 by telling aptitude to use the source lists for Ubuntu 9.10 (Karmic Koala).
Thanks to Nick Veenhof, mrkandy, and their many commenters, from whom this script is derived.
php_installed=`dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
# remove all php packge
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
# use karmic for php pakage
# pin-params: a (archive), c (components), v (version), o (origin) and l (label).
echo -e "Package: php5\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee /etc/apt/preferences.d/php > /dev/null
apt-cache search php5-|grep php5-|awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'|sudo tee -a /etc/apt/preferences.d/php > /dev/null
apt-cache search -n libapache2-mod-php5 |awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'| sudo tee -a /etc/apt/preferences.d/php > /dev/null
echo -e "Package: php-pear\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee -a /etc/apt/preferences.d/php > /dev/null
# add karmic to source list
egrep '(main restricted|universe|multiverse)' /etc/apt/sources.list|grep -v "#"| sed s/lucid/karmic/g | sudo tee /etc/apt/sources.list.d/karmic.list > /dev/null
# update package database (use apt-get if aptitude crash)
sudo apt-get update
# install php
sudo apt-get install $php_installed
sudo aptitude hold `dpkg -l | grep php5| awk '{print $2}' |tr "\n" " "`
#done
Of course, make sure to restart Apache when you’re finished.
Redesign: x + 3 v2
I’ve been remiss in calling attention to the redesign launched here a few months ago. May thanks to Stephanie for helping with the design.
There’s still a fair amount of tweaking to be done (isn’t there always?), and I can’t promise universal browser support.
I’m experimenting with a few newer CSS features. Notably:
- Headers use the Republikaps font, loaded using
@font-face - A fair number of drop-shadows are scattered throughout
- The border of the main content area is a combination of two rounded-corner boxes, the inner with a drop-shadow, the outer with an inset drop-shadow (note that due to a bug in WebKit, Safari and Chrome users may see a square outer border)
Much of the above won’t be visible to the 6% of my readers still on Internet Explorer. Frankly, I’m alright with that. In the past month, Opera’s 1.69% among visits to this site outranks IE6 and IE7 combined.
Let me know what you think, or call my attention to any bugs you might notice.

