The solution is to include sufficient fees in your transaction. Most regular transactions are 0.25 Kb, and current minimum fees (27th June 2016) are around 60-70 satoshis per Kb. (from
bitcoinfees.21.co)
You can set slightly less than the current price for the minimum, and can expect to wait upwards of 24 hours for the transaction to clear. Setting a little more will be very likely to get your transaction into the chain in less than ~6 blocks, but the situation is not static (big tx rate spikes immediately after could shunt you out of position in line) and the miners don't actually
have to mine your transaction, they choose to do it. That means they can choose not to, for whatever reason (or for no reason).