| Subcribe via RSS

Display Single Post on Home Page in WordPress

December 11th, 2011 | Comments Off | Posted in PHP, WordPress

Most themes have some sort of post roll that lists out the most recent posts on the home page. In most cases this is the ideal way to get your readers up to date on your most recent information. Say you had a more traditional website that displays what your company is about on the home page and maybe your recent or most read blog posts are relegated to the sidebar. So how do we display just a single post in that home page body section? Pretty simply it turns out.

Just prior to the php while loop (look at the file located in Appearance > Editor > index.php) set the query_posts method equal to the id of your post. So you’d have something that looks like this.

Display Alternate Sidebar Based on Page in WordPress

October 13th, 2009 | Comments Off | Posted in PHP, WordPress

I don’t know about you, but I get tired looking at that same right sidebar on every page of my WordPress sites. Not all pages are created equal, and some need to serve up different content based on where we are in the site. For my particular case, I wanted to display custom content to the last page in a checkout process. To do this we have to first determine which page we are on by looking at the $_SERVER['REQUEST_URL']. If we were on http://aspnetprogrammer.net/hello_world, it would return the value hello_world. Next, we set the queryValue of the page we are looking for then trigger our comparison. The strstr function in php compares two strings, telling us if the second is contained within the first. If it is, we display the checkout.php sidebar. Otherwise, we let the default sidebar load as normal.

Add Home Page Link to Menubar in WordPress Blog

October 11th, 2009 | Comments Off | Posted in HTML, WordPress

It is about the most basic thing in the world to start a menu navigation bar with a link to your home page, but for some reason many nice WordPress templates seem to have overlooked this essential element. It will list out your categories fine, but no go on getting you back to the beginning. Let’s fix that oversight. In your header file under Appearance > Editor (this file may be called something different depending on the template you are using), we’re going to look for a line of code that looks like this:

That is where these category options are getting inserted. Now to append a link to the home page to the beginning of these links simply precede the above line with the following code:

WordPress Replacing Ampersands in Javascript

August 19th, 2009 | Comments Off | Posted in Javascript, WordPress

As great as WordPress is for running a blog, it comes with more than its fair share of headaches for the developers out there. Today, I was putting some javascript code into the body of my post. Whenever you get more clever than basic text and html in the body of a post, watch out! So WordPress started chewing up all my ampersands and replacing them with & and of course the javascript was rendered useless. I searched high and low for a fix and nothing. I know there has to be a config file somewhere in this WordPress install that replaces those ampersands. I’m sure its for XHTML compliance issue or something like that, but I want to be able to rid myself of this intrusion. So while I didn’t find a solution, I did find a work around that should have occured to me earlier — just wrap the javascript up in its own file and make a reference to it from the post body. It would look something like this:

The key here is, if WordPress can’t process the javascript directly, it can’t mangle your ampersands. F%$kin’ A man!

Tags: ,

WordPress Running Slow on GoDaddy

August 18th, 2009 | 1 Comment | Posted in goDaddy, Javascript, WordPress

I don’t know what it is, but for the past week all my blogs have been running dog slow on GoDaddy. All my other sites (ASP.NET based) run fine. I contacted support and I got the ever so unhelpful “this problem is something on your side” or my personal favorite “you need to upgrade your account to a dedicated server.” What? You can’t support a measly blog, and you want me to shell out major bucks for a dedicated server? Not happening. After doing some investigation on the web, nothing could be further from the truth. Many, many, many people are having these slow crawling load times when running WordPress on GoDaddy. The solution — find another web host. Seriously, out of the four web forums I scoured no one had run across a solution past jumping ship.

The one host that kept coming up time and again in my research was Bluehost. Even WordPress themselves had Bluehost listed first on their list of recommended web hosts. Everyone kept saying their support was great and load times were very quick. I just got setup yesterday with them, and I’m busy pulling over files and setting up databases. I’ll check back in to let you know how it goes.

Update [8/27/09]: One week on BlueHost, and I’m happy to confirm that all blogs are zipping right along. No delays, no unbearable load times, none of that Godaddy crap. The problem definitely wasn’t on my end. You’d think they’d be able to at least run a little WordPress blog. Guess I expect too much. As far as the transition over to BlueHost, it was fairly painless. Basically, you just export your mySQL database to a file comprised of a bunch of SQL statements. After creating the cooresponding database on your BlueHost mySQL account, you just import the SQL file and all your data is up. Then just download all your blog files and restore them to the new folder location you’ve setup for the site on BlueHost. Next you need to point the wp-config.php file to the new database as follows:

Your final step is just to go into your domain provider and point the DNS record to go to BlueHost. The DNS servers you are looking for are primary NS1.BLUEHOST.COM and backup NS2.BLUEHOST.COM. Then you just have to wait for the changes to propogate through the Internet’s hub routers. I’ve seen it take as quick as five minute to a couple of hours. No rhyme or reason to it. Whalah you’re setup and you’ve left Godaddy’s interminable crawl in the past.

Oh with regards to support, BlueHost was very responsive. I submitted 4 requests as I was getting setup and they were normally back to me within 30 minutes to an hour via email, and I didn’t get a single boneheaded answer that was cut and pasted out of the knowledgebase that had absolutely nothing to do with my issue. Of course that was the norm with Godaddy’s hosting support and many other hosts I’ve used in the past. Very satisfied so far with the whole hosting experience at BlueHost.

Tags: , ,

Webhost4Life Web Hosting Sucks

July 3rd, 2009 | Comments Off | Posted in goDaddy, Web Hosting, webhost4life, WordPress

Let me tell about the week I have had, all courtesy of the incompetent techs running Webhost4life hosting service. The week starts with my Movable Type admin panel being mysteriously unavailable. The main site is still up mind you, but no way to actually edit or post anything. So the support request goes in, and they first try to change the main cgi file over to a pl file thus triggering a mountain of errors. Their response to this was, “can you figure out what all these errors are about?” You dumb idiot. You changed the file extension. This has worked as is for the past 4 years. Why do you now think changing the file extension is the answer? So another tech changes it back to cgi and gets me in. Great, but when I go to publish nothing has write access. A day goes by and now I can write to one directory, but not another. Still basically can’t post. Another day goes by, and I’m back to normal. Not so fast sparky. I get a seperate email that morning saying that they’ve switched servers on me overnight and so all my ODBC connections are now on the fritz. The site has effectively been offline for hours. It would have been nice to send me the email the day before so I could have the code gracefully fall over to the new server. Now that that is fixed, none of the image files work even though they are full qualified urls. Incompetance like this has to be rewarded. I’ve spent the last day pulling all the data down off the WebHost4Life server and loading it up to Godaddy. I’ve also put the blog on WordPress which makes my life so much easier. Moveable Type was a headache and a pain in the ass. Five years ago there wasn’t much better out there though. So that was my week.

Truthfully if this was WebHost’s first f$&k up, I could probably give them another chance, but this seems to be a perpetual issue. The site will go down for a couple to 10 minutes at a time then be right back up. No one has an explanation for what caused the hiccup. I keep running into file upload buffer limits where they have to clear something on their side. They always seem to be changing servers or screwing with something that breaks my site. Logically if you are going to have everyone point to the e drive as the web root, wouldn’t you maintain that drive letter when you relocated it to a new server? I know this is way too logical. The biggest irritant is just that they are never on top of things. They let issues sit for days at a time before responding. Customer support is not a high priority.

Please do me a favor and never use Webhost4life for your web host. You’re just asking for trouble.

Tags: ,

Disable Automated Line Breaks in WordPress – wpautop

May 12th, 2009 | 1 Comment | Posted in WordPress

Sweet Jesus this was way harder than it should have been. So I’ve been using Alex Gorbatchev’s SyntaxHighlighter (highly recommended to all the blogging coders out there by the way) to make my code look all pretty — preserve tab spacing, notch line numbers, color code everything nicely. It worked great except for one thing. Whenever I would have a line break it would insert a <br> tag following the line which would subsequently annoyingly show up in my code. It didn’t matter if the enter was hit in the WYSIWYG or in the HTML view, they always got added. It became a tad bit infuriating because nothing I did would stop this madness.

After much research, I discovered that WordPress has a function called wpautop which formats the page at runtime and inserts these unwanted tags all over the place. Its a great feature for the non-programmers out there, but there should be an easy way to shut it off for the rest of us. Thankfully for my sanity and yours, Urban Giraffe has created a plug-in that will disable wpautop. I tossed it into the mix, and it worked like a charm. The only GOTCHA is the logical one. WordPress isn’t going behind you to clean up your formatting mess anymore so you’ll need to start adding the appropriate break and paragraph tags where needed. With that said, if you have a blog with hundreds…thousands of posts that haven’t been formatted properly, you may want to think long and hard to determine if its worth the extra effort its going to take to reformat all those posts.

Tags: , ,

Professional Free News Template on BlogOhBlog!

April 24th, 2009 | Comments Off | Posted in WordPress

Doesn’t the website name BlogOhBlog! remind you of Bob Loblaw on Arrested Develoment? Oh I miss it. Look for the movie release in 2010. Anyway back to the subject at hand — WordPress Templates. ASPNETProgrammer.net uses one of blogohblog’s many stylish templates, Statement to be exact. When I was surfing around on their website this evening I spotted this cool, professional looking template called Digital Statement that reminded me of a CNN look and feel (see below). This will definitely will work for one of my future sites that’s working its way through the early stages of development in my head. The best part is that its free. If you are in need of a classy looking WordPress template, check out what BlogOhBlog! has to offer. They have both free and premium selections, and they always produce high quality work. Enjoy!

Tags: ,