Category Archives: PHP

Fleet tracking with AT&T location API

Hacks PHP Web Design

When I got approached by a client to deliver GPS tracking solution for an upcoming “Cloudy 2 With A Chance of Meatballs” foodimobile tour, I must admit I wasn’t sure where to begin. Building a website with map showing current location of the tour truck was something I haven’t done before and with due date looming I had to carefully think before making any decisions.

One of the first things I’ve thought of was a GPS device itself. What should it be, and how will I communicate with it?

continue reading »

Writing Twitter Bot, the “intellectual one”, in php

Hacks PHP Thoughts

What is Twitter? For many it is a place to brag about everyday life events and post pictures. Some use it to promote themselves, corporations and alikes try to provide “customer service” using Twitter and other folks are doing all sorts of things from selling knock-offs to completely illegal stuff.

This article is about how you can use Twitter to promote a site, service or anything you’d like to the tweeps.

It is apparent, that searching for a keyword or a key phrase and responding to all of those would take a lot of time, so we are going to use automated scrip (a twitter [ro]bot), which will do all the job for us.

continue reading »

Make your LEMP website faster by installing eAccelerator

Hosting PHP

The other day i had a discussion with someone about how fast Java-powered website are, because the code is compiled and serving a page takes a breeze. The point of discussion was me writing code using php, which is a scripting language and compiles code on-the-fly every time you make a request to the website.

So i decided to take a little experiment involving current LEMP (php-fpm/mySQL Linode VPS host) setup for the client’s WordPress blog and add eAccelerator to it.

continue reading »

Output specific post from a category in WordPress

PHP Web Design

Let’s say you slice a website and need a nicely looking block in a sidebar with one recent post from certain category. Like in case with this one below: Daily Style Quote.

Logically following you need to run “the loop” and ask WordPress for just one post from just this particular category.

Here we go:

<div id="dailyStyleQuote">
    	<div id="quoteText">
      <?php query_posts('category_name=Daily Style Quote&posts_per_page=1'); ?>
      <?php while (have_posts()) : the_post();   		
    	<div id="quoteBottom">
			<?php the_time('l, F j, Y'); ?>
		$category_id = get_cat_ID( 'Daily Style Quote' );
    		$category_link = get_category_link( $category_id );
            <a href="<?php echo $category_link; ?>">archive</a>
        <?php endwhile; ?>

Page permalinks in WordPress

PHP Web Design

Got myself puzzled for a bit while slicing a WordPress theme this weekend on how to get a permalink to a certain page in WordPress template, given that you know what’s page title. Use this:

<?php echo get_permalink(get_page_by_title("Page title here")->ID); ?>

So now in your template you can use like this:

<a href="<?php echo get_permalink(get_page_by_title("About")->ID); ?>">About</a>