Jul 12 2008

Tip on installing WordPress on a Network Solutions hosted site

I just set up WordPress on a Network Solutions hosted site for my step-mom’s new interior design business. As always, the installation was a cinch except for, as always, one thing that takes an hour to figure out. Namely, Network Solutions is part of that 1% the “handy installation guide” refers to that doesn’t use “localhost” as the value for DB_name.

For anyone else who has this problem, the solution is:

DB_name equals the IP address of your Network Solutions site.


Jul 2 2008

Partial redesign of Fungible Convictions underway

While the overall look will stay the same, it’s been about two years since I examined WordPress’ plugin repository and, now, its widgets. The main big goal at this point—consisting of some high-level fc_loop work—is to get two to four recent posts to follow in two columns below the photos (themselves below the main post).

I’ll list the improvements later but wanted to give a quick hat tip to Alax.info for helping me tweak the Google Talk widget. For anyone interested, you can now IM me any time I’m online using the “Chat with Andrew Whitacre” link in the sidebar.


Feb 3 2007

Proud papa

Yesterday a site I designed went live. My employer had taken over management of an online academic journal—the Journal of Humanitarian Assistance—but in its 1994-2006 version, the method was simply to post the text on static HTML pages or as PDFs.

When we took it over, it was clear there was a lot of potential for relaunching the site on blogging software—Wordpress—so that readers could give the authors direct, public feedback. While there are journals covering the same topic (Disasters Journal for example), ours is the only one set up to allow academic-quality writing with turnaround times of a month or less. This means, for better or worse, JHA isn’t peer-reviewed, but when a humanitarian crisis hits, researchers can get feedback almost right away.

Even though there was a built-in readership, I was shocked to fire up JHA this afternoon and see 9 comments on the newest article. It’s reassuring that after 24 hours a) the site works and b) the site works for the various kinds of people reading it. But the best thing of all is that something that challenged my coding knowledge ending up doing what it was intended to do, on time, and isn’t ugly.

There’s still more work to do. There are some bugs in the archives, our work-study folks will take months to get the 1994-2006 articles formatted and posted, and I haven’t done nearly enough testing for cross-browser compatibility, accessibility, and page sizes (the front page is 213kb, not acceptable for our readers in Africa). But it’s up, it works, and people like it. I’m very proud.


Jan 25 2007

Another post to confuse my mother

In response to yesterday’s post about tweaking a multiple authors plugin for WordPress, my mother wrote me an e-mail with a link to the post and the word “Huh?” I just made another coding breakthrough on a project (breakthrough being relative; I only changed one line of code), and will discuss it below, but first here’s a mom-level description of yesterday’s post.

I’m creating an academic journal website for work. The website will use the same blogging software that this site uses: WordPress. WordPress is nothing more than a bunch of files that make a very simple (though robust) website, but those files happen to be editable by anybody. Thus, thousands of people make improvements to the code in those files, and then they share those improvements by blogging about them or submitting them to a site that organizes such things.

One limitation in WordPress as-is is that each post can only have one author—to “have” an author on a post not only means they are given credit for that post but that their name is linked to more information about them, such as contact information, other posts they have written, etc. Having a single author per post is fine if your site is a personal blog or even if your site has multiple authors writing their own things. But for a site that will be an academic journal, posts need to have two or more authors, as research is often conducted and written jointly.

Thus someone had to come along and rewrite (“hack”) or add to (provide a “plugin”) to the basic WordPress code. The author of the website Tempus Fugit did just that. However, his plugin automatically granted “authorship” to anyone who edits a post. (He had written the plugin specifically for a WordPress user who co-authored posts with his wife.) But for an academic journal, that wouldn’t do. Editors of a piece are editors; they are not authors.

So I had to rewrite code in the plugin—or, specifically, delete the code that automatically added any post’s editor as an author.

Meanwhile…

I’m a big fan of a plugin called Timeline. It’s what generates the scrollable archive on this site. And I’m going to use it on the new academic journal site.

But there’s a problem. Timeline’s code is written such that it grabs not just the posts but also stand-alone pages. That means it thinks my academic journal archive should include the “About” page and the submission guidelines and, ironically, the full archives page (it archived the archive!). But there’s a simple edit to the Timeline plugin that fixes this:

On line 692 add the limit AND post.post_type='post' so that the query looks like this…


// Build query to get posts
$Query = << SELECT
post.*
FROM
$wpdb->posts as post
$FromFilter
WHERE
post.post_status='publish' AND post.post_type='post'
$Filter
ORDER BY
post.post_date DESC
$Limit
EOT;

Narratively, that means this… Select all the information from the table called “post” from the WordPress database called “posts” (which by the way we’re going to rename “post” for some reason). Filter out specific categories of posts if the user specified such ($FromFilter). Of that information we got from the table “post”, only get that information if the post_status happens to equal “publish” (as opposed to draft or private) and where the post_type happens to equal an honest-to-goodness “post” (as opposed to those stand-alone pages). Then when that information comes back, make sure it’s sorted by date in descending order.

So what do we end up with?: a list of every post on the site (not including stand-alone pages) sorted from most recent to oldest. The plugin then goes on to insert that list into the pretty, styled boxes that show up in our sidebar.

Done and done!


Jan 24 2007

Multiple authors per post in WordPress

Over on an academic journal site I’ve been setting up, I needed a way to assign multiple authors for a single post. Tempus Fugit developed a plugin to do just that, except it makes the assumption that anyone who edits a post should be listed as an author—true for blogs, not true for a site with editors posting others’ work. Here’s a simple fix, though, for anyone using Tempus Fugit’s multiple authors plugin…

In the plugin’s php file, delete the function that equates a post editor as an author:

function txfx_oa_add_author($post_ID) {
global $wpdb, $userdata;

if ( !$userdata ) get_currentuserinfo(); // shouldn't be needed, but can't hurt

$main_author = $wpdb->get_var("SELECT `post_author` FROM $wpdb->posts WHERE `ID` = '$post_ID'");

if ( $userdata->ID == $main_author ) return $post_ID; // the person who created the post is editing it... do nothing

// if we're still here, it must be a new author, so see if they are already logged as an author on this post
if ( $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = 'other_author' AND post_id = '$post_ID' AND meta_value = '$userdata->user_login'") ) return $post_ID;

// if we're STILL here, it's time to add this author
add_post_meta($post_ID, 'other_author', $userdata->user_login);

//and we're done
return $post_ID;

}

And at the very bottom of the file, to keep the file from breaking, delete the commands to add that now-ignored editor as an author:

add_action('edit_post', 'txfx_oa_add_author');
add_action('save_post', 'txfx_oa_add_author');

Done and done! Adding an author is manual now—you just add a custom field called “other_author” and type in the second (or third or fourth) author’s name in the “Value” box. And so long as it matches the name of a registered user, that person will be duly added as an author to the post.


Dec 5 2006

Site credits

Thanks first to all you Fungible Convictions readers. The stats show you’re very loyal, with about a quarter of all visitors returning regularly.

The last couple months saw some significant improvements to the technological guts of Fungible Convictions, none of which I can take credit for. If you are a lit blogger and/or WordPress user, I’m pleased to recommend the following goodies that are each recent additions.

WordPress plugins:

Income and networking:

  • Metaxu Cafe Litblog Network: Fungible Convictions is now a member. Many thanks for their profiling Fungible Convictions when FC became their 400th member blog—and for pointing me and others towards so many excellent writers.
  • Amazon.com Associates Program: Foolproof, money-making linking to books that interest Fungible Convictions readers. They also provide a spiffy linking feature that generates an information window alongside a link upon a user’s mousing over it. For example: WordPress 2 (Visual QuickStart Guide)
  • Brainiads: A recently launched Metaxu Cafe ad service featuring better ad targeting.

This site is the best thing that’s happened to my reading and writing life. I’ve received countless recommendations for great books, learned a lot of PHP coding, gotten the chance to interview editors and writers I admire, and discovered hours and hours of great blog-reading via links in your comments and e-mails. For all of that, my sincere thanks.


Sep 8 2006

Applying my "stopwriting" template

For a while—that is, a while ago—I was working on a WordPress template specialized for creative writers. It can be found kind of here but properly at www.stopwriting.com.

Fungible Convictions will look ugly for a bit since I’m applying changes live but also don’t have tons of time to commit to the update. Bad juju, I know.

If you have any comments, feel free to leave them here or at stopwriting.com.