kieranbarnes Independent PHP, WordPress & CubeCart Programmer

Splitting WordPress content with ‘more’ on single pages

Posted on September 12, 2011

WordPress uses the "More" button to create a small snippet of content, usually used on the blog page, to create article teasers and such. WordPress ignores the "More" function on single posts, pages and several other pages.

Here's some code of make use of the "More" function on single pages and single posts. Perhaps splitting the content into columns or hiding extra content in an accordion or pretty much anything. Look, I'm going to press the "More" button right now.

WordPress Archive Redirection (Single Items)

Posted on August 24, 2011

If you are using the standard archive-[custom-post-type] and single-[custom-post-type] theme structure for your Custom Post Types, you may come across a situation where the archive-[custom-post-type] needs to redirect to your first custom post. So, rather than duplicate code across templates. Duplicate code is messy code. You can use the wp_redirect function.

[Snippet] How to install cron (crond, crontab) in CentOS

Posted on August 23, 2011

Sometimes small installations of CentOS don't come with cron. Here's how to install cron easily and quickly.

  1. yum install vixie-cron crontabs
  2. /sbin/chkconfig crond on
  3. /sbin/service crond start

See my retro post I hate vi. (aka Changing your default crontab editor) for how to change the editor from vi to nano.

 

Filed under: CentOS, Linux 1 Comment

Overwriting WordPress loop parameters per page

Posted on August 22, 2011

In some instances you may want to overwrite WordPress loop parameters per page.
For example, a recent request from a client

"Can I have all my portfolio items on a single page?".

Yes, client, you can. "Portfolio"  is a custom post type. Using Everett's Custom Content Type Manager. The theme is fully structured so it uses single-custom-content.php and archive-custom-content.php.

Prevent images from displaying while loading with AnythingSlider

Posted on August 17, 2011

AnythingSlider is just another jQuery slider effect, except we can embed any content as it uses a semantic unordered list HTML (5) structure.

My recent client wanted a mixture of HTML, videos and images, which means you get the nasty flash of the UL elements whilst your browser renders the window. Apparently its called Flash Of Unstyled Content (or FOUC). Whatever. Its called really annoying to me. So here is a bit of code that should be included in the default anythingslider.css but isn't for some reason.

Tagged as: , , , Continue reading

[Snippet] Formatting the date in twitter XML feed

Posted on August 17, 2011

The date in the Twitter XML feed is daft and ugly! It reads [created_at] => Wed Aug 03 23:34:35 +0000 2011

We can easily format this with PHP using date() and strtotime()

  1. $latest_tweet_date = date("l M j \- g:ia",strtotime($tweet->status[0]->created_at));

 

Tagged as: , No Comments

Using the Twitter XML Feed in PHP

Posted on August 17, 2011

Parsing the Twitter XML feed for a user in PHP is now super simple.

  1. $username = 'Kieran_Barnes';
  2. $format = 'xml';
  3. $tweet = simplexml_load_file("http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}");
Tagged as: Continue reading

Disabling Core Dumps

Posted on August 17, 2011

I recently found a (cPanel) server was generating over 100Gb of core dumps every time a bad PHP script died or Apache died. Writing these generally useless (who actually debugs these on a live web server) to disk is a pointless waste of disk I/O, especially in a VPS environment.

Here is two methods of disabling core dumps;

Custom Shopp Gallery with FancyBox

Posted on August 9, 2011

Following on from a previous post Custom Shopp Gallery, here is how to do make a custom Shopp gallery with FancyBox.

Removing l10n.js in WordPress

Posted on August 9, 2011

l10nn.js is a JavaScript library that enables localization through native JavaScript methods, gracefully degrading if the library is not present. WordPress 3.0 enables l10n.js by default and most of the time if you are working on single language, non-localised WordPress sites, you can safely disable it and save yourself a few bytes of code at each page load.
Clean code is happy code!

Page 4 of 34« First...23456...102030...Last »