Ordering WordPress Posts By Any Order May06

Ordering WordPress Posts By Any Order...

WordPress has a lot of really clever ways to order posts, which can be used to order in almost any way. However, during a recent project I needed to order posts based on one of their meta values, but those meta values needed conditional if statements in to denote what values they should take. The scenario was such that I needed to order posts based on a numeric value in their meta values, ascending in number, but if that meta value did not exist, or was 0, to be placed last. So I wanted an order along the lines of: 2, 25, 39, 48, 0, null, null At first this seemed impossible, and I was left head scratching on how to carry out the order while still including core WordPress mechanisms such as paging. WordPress, by default, doesn’t include an orderby clause where you can just set post ID’s (ie order => (8,99,102,45,22) ). But then I remembered that since version 3.5 WordPress added this clause: ‘post__in‘ – Preserve post ID order given in the post__in array (available with Version 3.5). I then realised, that if I created an array in the right order, and then passed that to the post__in array I could achieve my desired result. Final code is below: PHP $arr = array(); // First loop through all posts and create an array of the post_id (key) to meta_value_num (value) $args = array('nopaging' => true); $query = new WP_Query($args); if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); $exp_date = get_post_meta(get_the_ID(), 'the_meta_value', true); // If the meta_value is null or 0, make it huge so we can order accordingly if($exp_date == "" || $exp_date == "0") $exp_date = "999999999999"; $arr[get_the_ID()] = $exp_date; endwhile; endif; wp_reset_postdata(); // Sort the array in ascending order asort($arr); $args_posts_in...

Jurassic Coast Challenge Apr04

Jurassic Coast Challenge

The hills were steep and often, the miles many, the terrain varied and frequently difficult, but the sun was shining and the steep hills, varied terrain and many miles were all part of the challenge as Han and I set off to try and complete a marathon a day for 3 days over the rugged Jurassic Coast down in south Devon. Travel back 6 months and it was yet another sunny day as Han came back from visiting her brother with knowledge of this formidable challenge now planted as an ever growing seed in her mind. She had seen some crazy runners plodding along the picturesque coastal path in Weymouth, around 15 miles into their 2nd day of the three 26.2 mile routes. “This could be a fun challenge?” she thought “Sounds like a whole lotta crazy!” I replied And so the seed took root, the seed grew, and the seed blossomed until we found ourselves listening to the organiser of the VoTwo Jurassic Coast Challenge explain the OS driven map route for day 1 of the 3 day event. The event in question was a 78mile route along the picturesque south coastal path starting at a non-descript hill 26 miles west of event HQ in Weymouth. Each day was a full marathon distance self-guided run (no markers or race signs), following the coastal path step for step, finishing up on Shell Bay a few miles North of Swanage 3 days later. The first day had a relatively late start of 11:30am, and as we watched the eclipse swallow the land into darkness before releasing its enveloping cloak to reveal a glorious sunlight day, Han and I took our tentative first steps on our mammoth journey. We had been casually pretending to not peak at the weather report the week before, not wanting to jinx the outcome in some form of uncertainty principle belief, and we had either played our cards just right, or more likely had lucked-out, as the sun was shining but not scorching, the wind was a confortable 4-5mph, and the first mile was a downhill saunter with wonderful vista’s of high rising cliffs and golden beaches ahead of us. We jogged on down, feeling light footed and free as the mass start of the 100 or so runners (and one dog) gradually thinned out and found their natural gaits and rhythms that would hopefully see them cross the finish line anywhere between 4 and 9 hours later. Day 1 would see two monster hills approach and test us within the first 4 miles, but at such an early stage of the challenge our legs were still fresh and still warming up, and the vistas that we were rewarded with were worth the un-guilty walking that had seen us slowly traverse the 200m peaks. We stopped and briefly ate at checkpoint 1 a quarter into the first days distance before hitting probably the hardest part of the full 3 days; around 2-3 miles of intermittent shingle beach. This stuff just sucked all energy out of you, as each step just jostled the stones beneath your feet as you sank into their opening and closing chasms of energy sapping hard work. “I think it will be easier if we just try and run across it” Han propositioned as she skipped elf like past every single other runner who was walking through the shingle pathways. Not one for being left behind I grumbled my ascent and 15 mins later we were out the other side and closing in on checkpoint 2. As we neared the half way mark of the day Han started to feel some pain in her left knee, but shrugged it off as we gorged our way through cheese and pickle sandwiches, my new running favourite of cheesy cheddars, while stuffing flapjack and some crisps for later consumption into my running bags pockets. As the...

A year later… and still running Feb24

A year later… and still running...

It seems fitting that one year on from the last post, as I was speedily traversing the southern hemisphere to see my sister in New Zealand, that I come back to revisit this blog and try and record once again life’s little adventures and twists and turns. It also seems strangely fitting that this new post, in an attempt to rekindle an online pubic diary of sorts, also starts with a running post, just like the first post exactly two years ago. Seems February is a chequered flag month for me, lets hope this one carries on for another lap at least ….. Last Sunday saw Han and I once again waking up with the pre-dawn calling of birds, as the sun was slowing rising up from its nightly slumber to bathe the countryside between Oxford and Aylesbury with its warming glows. Han and I were up and changed, ready for our first long distance race since I had competed in Guatemala over a year ago, and were trundling along to a small town called Wendover just south of Aylesbury. We had both entered into the Trailscape Wendover full marathon, a 4 part running series that operates a 10km, half and full marathon distance trail race series through the winter months in England. Han, being the organised girl she is, had entered months ago in the full marathon distance, where as I on the other hand had pondered whether to race at all; I had a korfball tournament the next day competing for Wales and wanted some form of freshness for that. When I finally made my mind up to enter the half distance, I logged on only to see that it was sold out, and when looking down the distance ladder, also saw...

A New Chapter Begins

As we left the beaches and volcanoes of Southern Nicaragua our next stop was to visit the two colonial towns of Granada and Leon. After the colonial history burst we planned to visit the highlands of Nicaragua, to a town called Esteli, and thus complete our set of the travelling hotpot of altitudes, climates and adventure. Although a very much subconscious decision at the time, in hindsight it was evident that we were searching. Searching for what, we weren’t sure; some energy, some drive to carry on, a rise out of a travelling slump that we found ourselves in, some passion and excitement at the wonderful cultures and views that we were experiencing. We had left Costa Rica a mere 8 days ago before entering the cobbled streets of Granada, but something in us had changed. We were tired. Tired both mentally and physically. The gregarious imposing churches were no longer exciting, intriguing or gregariously imposing. The lakes, volcanoes, hills, town squares, museums, local food, beers, cultures and people were either becoming common place or annoying. We didn’t have the enthusiasm or drive that we started out with, the enthusiasm or drive that bought us to these far off magical lands, the enthusiasm or drive to get excited about the next city or town. We wanted to give these amazing places more of our time and passion, but were finding it increasingly hard to find that energy as easily as waking up and being enthused about the day ahead. We were in the travelling blues! I’d been in them before, seen them before in other people, experienced them first hand; this weird phenomenon that around the three to four month mark of a long trip backpackers loose the focus and wonder what they are doing. Some of the time people come out of them; sometimes they don’t and leave early, other times people carry on in vain attempts to find the lost passion that they had when they first jumped off the initial plane into the adventure that awaited them. We knew we had to do something and spent a few nights over a few beers talking about what we personally wanted over the next 2-3 months. Our plans changed almost hourly, some purely through hypothetical conversations, some more defined and purposeful like trying to buy bus tickets to Panama, and others through research with twenty different flight prices and times open on the laptop. What did we want? We came to two conclusions. Firstly that we needed a change; be that in culture, lifestyle, or continent, and secondly that we needed an end date. We realised mentally we needed a stop point, not a vague open-ended season that we might be home, but a flight booked home, or at least to some next stage in our journey. We battled these inner demons for a wile before coming to the conclusion that travelling through Central America was coming to an end for us. With my mum and uncle arriving into Mexico for a holiday we used that as a date to meet up with them, and then devised extraordinary plans afterwards of myself flying to New Zealand then onto Vancouver to see my sister and friends respectively, with Han flying to Tel Aviv to visit a friend who had moved there previously and she hadn’t seen for a while, before both meeting back up in the UK near the end of February. Suddenly our journey to far away lands sprang back to life. We had an end point, a focus, a drive, a goal to work towards; the grass started to grew greener on our side of the fence, the sun was not a hot sweat inducing annoyance, but a warmth giving ball of energy, and we were once again motivated, intoxicated with excitement of what was to come and what had come to pass. We made future plans...

Nicaragua – The Beginning

Nicaragua, the largest of the countries in the Central American isthmuses, a very much up and coming destination for backpackers and holiday tourists, is often cited in magazines and websites as a top holiday destination to discover and explore. It was a renewed sense of adventure that we passed through customs and border control relatively hassle free, jumped on a bus after shoving off insistent taxi drivers, and made our way to San Juan Del Sur. Zipping past kilometres of wind farms that had been constructed in the last couple of years as part of the governments promise to decrease air pollution, we passed the hour happily scenery and people watching from our old American yellow school bus. We were heading North along the Pan American Highway with views of two majestic volcanoes on our right, with the Pacific ocean somewhere in the unseeing distance on our left making our way to Rivas, a city where we were to change buses for another smaller local bus to our final destination. After jumping off the bus and walking to the other bus station, we were, as usual, harassed by a host of taxi drivers who had dollar signs in their eyes as they saw another two gringo’s. We had read that often it can be cheaper if you get four of you in a taxi from Rivas to San Juan Del Sur, so we bartered and negotiated a price that we were willing to pay for two of us. Sure it was more than two bus rides would have been, but it would be direct to our hostel and a lot more convenient and comfy. Being surprised by one taxi driver who seemed considerably cheaper than everyone else, we checked, double checked and triple checked the price and destination, but he seemed to be sticking to the low monetary figure, and we figured that he just wanted the business. Move forward 5 minutes and you would have seen me leaning out of a taxi car door as it trundled along a busy street, slowly but perceptively moving into barren areas, shouting at the taxi driver to stop and causing a commotion, as Han fretted over a large knife the taxi driver had just displayed on the seat next to him. Magically and amazingly the price had just doubled as soon as we made about 100m from taxi rank that we were understandably unwilling to pay. Shouting in our pigeon Spanish that we wanted to get a bus and let us out, it was with nervous requests that the taxi driver got out and opened the boot for us to get our bags. We walked back the 300m to the bus station; we were surprisingly calm and serene about the whole situation. If we had managed to get to more desolate areas a couple of minutes further down the road, things might have been different, but opening the door and shouting whilst still in relative busy streets seemed to have sorted out the situation and 10 minutes later we were on a bus to San Juan Del Sur reading the guide books about the up-and-coming surfer beach town. Over our two nights at this black hole of a down under backpacker area; Aussies seemed to converge on the party driven “Funday Sunday” town to never escape and be lost in an eternal struggle of finding themselves on a bus out of there but not missing the next big party, we stayed at a hostel with an amazing infinity pool overlooking the ocean that was renowned for parties, as well as a downtown sandy floored type A backpacker abode. The main highlight though was the main reason that we wanted to visit the area, the Olive Ridley Turtles and their arribadas. In only 7 places over the world a phenomenon known as an arribada happens; thousands upon thousands of turtles converge on...

Monteverde

After sitting at the Costa Rican equivalent of a souped up Sunday dinner style KFC for 90mins, our pre-booked shuttle screeched into the parking lot under the burning midday sun, we threw our newly lightened loads into the back, along with our newly re-energized bodies and pulled off onto the highway. Two hours previously we had said our farewells to Han’s parents, Alan and Margaret, who had come over to Costa Rica for the festive period, and we set off on a sun bleached New Years Eve making our way to the cloud forest of Monteverde. We had had a wonderful two weeks with the Agers but were looking forward to getting back on the backpacker trail, as well as heading towards cooler climates as we made our way into the highlands of Costa Rica. We arrived amidst blowing winds and trouser wearing weather, checked into our hostel of choice and revelled in the fact that our bed had 2 large fluffy covers to keep us warm in the night. After backpacking for 3 months through Central America, often sweating through nights of restless sleep, having showers only to need another one shortly afterwards, positioning noisy fans to point at the optimal point to cool both of our bodies, the chance of being able to slip into a warm bed whilst the wind rattled the roof and cool air breezed through the cracks in the wall, was a welcome relief and recuperating rest. Please specify a Flickr ID for this gallery Moving away from the oh-so British proverbial talk about the weather, however, our time in Monteverde was a great restart for our backpacking lives. With an abundance of wildlife in the form of hundreds of species of birds, thousands of species of fauna,...

Costa Rica and The Agers

We touched down on Costa Rican soil excited to be only a couple of days away from seeing some familiar home faces, and only a couple of days away from Tetley tea bags and a supply of Cadburys Chocolate that even Han didn’t manage to consume in the first 48 hours. Han’s parents were making the journey over for the festive period to join us for 2 weeks exploring the Pacific and Caribbean coasts of Costa Rica, and we had arrived a day ahead of schedule in the capital of San Jose. We had originally planned to take a 22-hour bus all the way from San Salvador, through Nicaragua, stopping off for food at a Burger King (no, really) before clearing another border and alighting in San Jose a day later. However, due to Some miscommunication with our Spanish and the tellers English Some extremely heavy usage of buses just before the holidays See (1) We found ourselves stuck in San Salvador, knowing we had around 48 hours to find a way to Costa Rica. With options slowly dwindling, and the prospects of sitting on really bad buses for over 40 hours, swapping, changing, money altering, food finding, and more swapping of buses not really hitting the ‘this is how life should be’ big button of fun, I made the executive decision to buy Han an early Christmas present and to take to the airs. Around 1 hour after take off, a mid air meal, free beverages and a smooth landing, my mind was happy at it’s decision and we found ourselves taking the relatively clean and orderly Costa Rican bus service to the capital away from the airport. My first thoughts of Costa Rica were one of a developed country, with a large influx of American merchandise and money, buses that have designated spaces for large oversized backpacks and taxis that charge by the meter. It was a relative breath of fresh air to arrive in a country and not have to figure out by how much the taxi driver or bus driver was ripping off the white faced Gringo. Founded in 1738 and lying in a valley surrounded on two sides by imposing volcanoes, we spent a fun morning pottering around the markets, walking the streets and seeing the usual tourist sites of a theatre, some churches and an ex-fort-turned-museum. After a break for lunch, where cheesecake was found, and found to be tasty, we then went in search of a church that the Lonely Planet recommended and soon found that first impressions are like judging the proverbial book by its cover. Once we scratched beyond the surface, we delved deeper into packed streets, the markets, the darker alleys and the rubbish filled gutters; a chaos that only works because its chaos. Seen from above the packed non-pedestrianised streets would look like an army of ants marching forever in random directions with no apparent rules or purpose. Hundreds, if not thousands of people, milling, swarming, walking, shouting, bumping; cars honking, pushing, shoving through the human mass. We spent an hour in search of the church, which we eventually found, and quickly decided that it was time to try and head back to the relative calm and safety of our hostel. San Jose to me felt like a mixed bag of westernised changes that were attempting to boot polish a chaotic, over populated city with a national psyche that in parts still wasn’t ready or wanting to change. You had areas of big chain stores, wide streets, clean malls, brands that I knew and then you had the ‘real’ Costa Rica with packed markets, shouts, calls, fume churning buses and the usual array of cheap street food and haggling. The next day was full of excitement from both parts of the Ager Family. We held up our lovingly created ‘Alan + Margaret’ signs at the arrivals, wondered where...

Juayua

Juayua (pronounced ‘why-you-er’) is a quant little town, founded in 1577, nestled up in the mountains of El Salvador that is famous for its food festival that lines the streets every weekend. For this reason we had pushed back our visit from earlier on the week and arrived at the cobblestone-strewn colonial town early on Thursday afternoon. The email directions of 5 blocks east and 3 blocks north from where the bus drops you off were surprisingly accurate as we lugged our luggage through the town square to our hostel we had reserved previously. The owner, Darren, a devout Ipswich Fan from England, was more than accommodating and the place had that great feel when a westerner manages to throw in some western comforts amongst the character and traditions of a local hostel. After successfully navigating the often crazy and misguided El Salvadorian bus system, changing buses in record time in the functional yet dirty town of Sonsonate, we had arrived at Juayua at the pleasing and refreshing time of 11am, so still had a full day of fun ahead of us. We quickly organised a tour for later that day to see the local waterfalls that inhabit themselves, conveniently, a pleasant 4km walk away, passing through a local village and into the jungle strewn surrounding countryside. Please specify a Flickr ID for this gallery Our guide only spoke Spanish but that only forced us ‘practicar sus Espanol’ (still probably wrong), and we had a good hour traversing down the hill, chatting about local happenings and history and being shown the local fauna, flora and coffee plants that inhabit the area. After a detour to follow a trickling stream we arrived atop a precipice that overlooked a majestic waterfall cascading over the cliffs 100m away. Toppling over 7 or 8 different cliff edges, the rushing waterfalls appeared from within the dense forest and disappeared amongst the enveloping jungle below, with only the sound of the river giving any notice that the water flowed beyond our field of vision. We carried on our water adventure by visiting some different waterfalls shortly after, these ones however spanned over 500-600m in width, broken up by cliffs and jungle, and allowed us to swim and play in the cooling fresh waters. The highlight however was the cave system that had been built between the falls. Originally built for irrigation purposes for a local water plant, they now allowed tourists and locals alike to slowly walk neck high in water, through dark and echoing tunnels, barely big wide enough for a human to turn around in. After a fun, refreshing, pleasing 40 minutes we changed back into our hiking shoes and trekked back up through the winding paths and plantations back to the hostel. It had been a good day, managing to move towns safely and conveniently, as well as visit some sites, sounds and senses later on in the day, and we sat back enjoying our ‘1 free beer’ from the hostel, watching a film in the lounge in the quiet hotel with the hostel staff. We had opted to stay in Juayua until Sunday morning, where we were planning on heading back to the capital to sort out a bus to Costa Rica, and with Saturday given over to gluttonous pursuits at the food festival, that gave way to Friday for exploring the sites and town on the 34km ‘Ruta De Flores’. After the usual morning activities and picking up some bread from ‘El Salvador’s Best Bakery’, which we had ordered the night before, we jumped on the old dilapidated American School bus and started to loudly rev our way onwards. Lightened, for once, without cumbersome backpacks we trundled off in roughly North Westerly direction to visit the three towns and a coffee plantation we had penned in to see. Please specify a Flickr ID for this gallery The first town offered...

Los Cobanos

With the only tourists in sight, we jumped off our old American yellow school bus into the dirt track at the edge of Los Cobanos. Not being suddenly bombarded by touts, taxi’s and tourette driven money changers was a breath of fresh air, and we were soon realizing that El Salvador is an often missed out gem in the backpacker circuit. The minus side however is that Spanish speaking is a must when you’re trying to find a hostel of choice, or directions to somewhere that can house two weary travellers for a couple of nights. On the plus side though, everyone is so helpful and friendly it wasn’t long before we were walking along the beach, stepping over the ropes that were holding boats at bay along the coast, through dark shack alleyways that lined the ocean-lapping sand and through to the other side of this isolated fishing village to one of the hostels that the Bible (the Lonely Planet) mentioned. We were quickly shown our room (a dorm to ourselves) on this beach fronted ‘probably-was-beautiful-when-it-was-built-20-years-ago-but-is-now-a-bit-in-need-of-repair-and-love’ hostel, just in time for sunset and some pupusa’s on the beach. Please specify a Flickr ID for this gallery The fishing village of Los Cobanos is small, so small in fact that you can wander its 2km length in 20mins, and it could be roughly described as two distinct parts; the slightly more upmarket shack esque ‘bars’ and hotels, and the slightly more down-to-earth fisherman’s wharf, both of which are comprised of walking along the beach, or through and around its shacks and houses that are thrown up randomly along the coast. The fisherman’s wharf gives you cheaper food, real hard-graft life and straight-from-the-ocean fish sales, along with some stares and laughs, where as the other...

Firework Ridden Bulls

We crossed the border of Guatemala into the lands of El Salvador with open minds and ready backpacks. El Salvador is an often avoided backpacker destination, with travellers opting to shoot through it on a nice cosy bus, flying out the other side into Nicaragua unscathed and hassle free. The very nature of this though is what bought us to this intriguing country; we were looking forward to getting off the Gringo trail, experiencing towns and cities where tourists were infrequent and where our lingual dexterity would be put to the test. Our adventure though didn’t start well. After clearing customs and wondering why no stamp was needed in the passport, we alighted at San Salvador bus terminal to be greeted by obnoxious money driven taxi drivers who knew they were our only option of finding our hostel of choice. After some fierce negotiations and joining up with another foreigner we settled on a price and headed on our way. It left a slightly bitter taste in our mouth; that the first contact with El Salvadorians was mixed with greed and stubbornness, but nevertheless we arrived at our hostel around 10:30pm and crashed out with thoughts on moving on quickly the next day, heading West to the town of Juayua. The backpackers privilege of freedom and drastic life altering decisions being made on the fly, however, was bought into play the next morning as we chatted to our host and made internet checks on transport options throughout the country. Although roads exist like a spider web of connectivity throughout the land, in a twist on the ancient Roman proverb, all roads lead to San Salvador, which means that any links from one stop to another would involve a change in El Salvador’s capital. We altered our plans that morning and decided instead to head to Suchitoto a few hours North, allowing us to hit the beach town of Los Cobanos before finally settling at Juayua the next weekend – giving us plenty of time to experience the food festival that the town is famous for. I hastily emailed the hostel I had booked in Juayua to change to the next weekend, and booked Han and I into, for our 5 year anniversary, what Lonely Planet described as … ‘Without a doubt this is one of the best places to stay in El Salvador. A posh boutique hotel set in a restored 200-year old home, high-end Salvadoran art, antique and modern furnishings, custom-made doors and several gurgling fountains set the scene for six immaculate rooms.’ I put my credit card details in, was amazed as again they were accepted by my grudgingly obliging bank, and we set off, the hotel a surprise. The rural farming population, 6 elderly smiling ranchos with their machetes slung across their backs, the colorful, the weird, the wonderful, and one other gringo, piled onto the market good laden bus and trundled North through the country. Stopping seemingly randomly for anyone who stuck out their hand, and some who didn’t, we slowly but perceptibly got more and more cramped until the ‘maximum 49 passenger’ stickered bus was holding around 90 people, before my vision got impaired by a man wielding a large broomstick that was a holder for another 25. Edging my backpack, my day sack, Han’s backpack, my juggling ‘fun bag’ and our food bag into tighter and tighter corners, trying to not be the stereotypical ‘annoying gringo who carries too much’, I got as comfy as possible and held on. Please specify a Flickr ID for this gallery Three hours later on the two-hour journey, with the bus slowly emptying as passengers jumped off at random grass strewn village lanes, we trundled into an amazing colonial town, piled the baggage onto our unwitting bodies and strolled down to the amazing hotel. We checked in, somewhat embarrassingly with our backpacks, smelly clothes and obvious biscuit...

Lago De Atitlan

In a break from my adjective strewn writing, and with an attempt to help you all catch up with our wanderings and amblings throughout Central America, this post comes to you in the form of pictures and simple sentences, just like when you were young. So sit back, get yourself a cup of tea, wait for the page to load up the pictures and enjoy…. Arrived at Lago de Atitlan in Panajachel. Energetic small tourist town on the edge of a beautiful lake. Met Ratita, the cutest little kitten who thought she was a tiger! 1st December. Ran the Lago de Atitlan Marathon. Coined as ‘One of the top ten hardest adventure marathons’ by ESPN, this gruelling marathon broke me. 42km with some ridiculous elevation gain, reaching 2500m at one point. Amazing though, just amazing. Han got her hair braided to fit in with the typical gringo traveller. Recouped and boated over to San Marcos with Richard and Bev (two other marathoners from Canada), a chilled out hippie esque town on the lake. Han and I moved to San Marcos for 3 nights. One night in a hostel with hard wooden beds, then moved to an amazing hotel for the same price round the corner. We relaxed, juggled, swam and ate out in this intriguing, holistic, vegan strewn, home grown town. Went on a beautiful run around the nearby hills around the lake. Got the boat to another town on the lake, San Pedro, and spent one night there, visiting a Friday Market at Santiago De Atitlan. Jumped on a mammoth journey, involving 4 buses and one border crossing to make our way to San Salvador, the capital El...