Customizing WordPress Themes with Advanced Custom Fields

Summary:

  • Create a specific post type with CPT UI plugin
  • Add specific fields, to the new post-types using the Advanced Custom Fields plugin
  • Give new fields an id – so that you can then edit the styling with CSS

See our WordPress for CSS blog post for more information on customising CSS – this will be the next post to be published



Custom fields is probably the easiest way to implement significant layout changes to a WordPress theme.

It is also a great way to provide a client with specific pages, that they can populate and publish themselves.

It obvisouly helps, a lot, to know HTML and CSS, and ideally PHP and Javascript, but you should be able to effectively customise designs to your own, and to your clients’ needs by using plugins instead (along with the Customize features now available on WordPress sites.

If a client is very specific about a design, it can a be a bit of a nightmare if you are not savvy with editing WordPress CSS, HTML and JS – Advanced Custom Fields makes it easy – and easier for both you and your clients to update when required – by changing the visual editor in wp-admin to make it as simple as possible.

In fact, I first came across Advanced Custom Fields, when I worked for a UK Tourism company, and the Web Agency amended pages using the plugin.

Step by Step

  1. Sort your hosting and domain out. Hostgator is decent (not an affiliate link)
  2. Backup your website (you should do this before installing new plugins – ironically, you made need a plugin to do this!)
  3. Install the CPT UI WordPress plugin – so you can create custom post types
  4. Install Advanced Custom Fields WordPress plugin – so you can create, well, custom fields etc on your pages and posts.
  5. Activate both the CPT UI WordPress plugin and the Advanced Custom Fields Plugin

Creating Fields with Advanced Custom Fields

Once you have installed – and activated the Advanced Custom Fields plugin, you should see a menu item on the left hand side; called “Custom Fields”

Image Source

To create a new field:

  • Click the “Add New” button next to “Field Groups” at the top of the page on the Custom Fields tab/menu item
  • Give the Field a Name e.g. “Product Description 2”
  • Now click the blue “+Add Field” button (near the top, to the right)
  • Now fill in the items required:
    – Field Name – give it a descriptive name – e.g. Product Description 2
    – Field Type – for text entry/a text box – choose Text
  • Most items are quite straight forward – the Location part is very important thought – as this dictates on which pages or posts, this field will appear.
    For my wooCommerce store, I have chosen:
    Post Type – is equal to – product
    so that I get the text field on all my product posts.
advanced custom fields - location
  • when you are happy – click the “Publish” button on the right hand side.
  • Now when I create a new Product Post/Page – I have the option to add a second description via a text box:
Product Text box
“Product Description 2” is now shown at the bottom of the page

Other Text Fields that might be appropriate for a Product could be things like:

  • Manufacturer
  • Year
  • Price
  • Condition

You could also set the fields to “Required” – so that a product could not be posted to the website without all of the above details. This is particularly helpful if you have multiple people working on the same site.

Remember that Year and Price would be a “number” and not a text field.

Add A Rating Box Using Advanced Custom Fields

  • Click “Add Field” button
  • Give the Field a name in Field Label & an actual Field Name
  • Add Instructions for the admin-user
  • Add a min and max value, e.g. 0 and 10
  • Step size – 1 (means can’t give 1.5 etc. has to be a whole number)


Combining Advanced Custom Fields with Custom Post Type Plugin

  • Install CPT UI plugin and activate it
  • Add a new post type by clicking on the relevant part of the side menu to bring up the CPT UI options
  • Fill in the basic settings:
    Slug – what will appear in the URL of these posts
    Singular – e.g. “Offer”
    Plural – e.g. “Offers”
  • Add Post Type – it should appear on the left hand menu/nav

Go Back to CPT UI – this time click on !Edit Post Types”

Minimize or just skip over the “Additional Labels” section

Under “Settings”
– Has Archive – change to “True”
– Menu Position – Change to “6” so it appears below normal posts
– Menu Icon – Change this to a relevant icon – 50 x 20 pxls

Now – when you go back to the Advanced Custom Fields section of the menu/backend – you can add specific fields to the “Offer” post type:

Advanced Custom Fields and Custom Blog Tpe

Positioning Fields on the Page

Simply use the options (in Settings) that custom fields gives you for positioning the field:

You can also add a class and id, so that you can edit the fields using CSS (see our next post about WordPress and CSS!)

Insert Blank Rows at Regular Intervals

Need to:

Hold down Alt & F11 to bring up VBA.

Add below code:

Sub InsertRowsAtIntervals()
'Updateby20150707
Dim Rng As Range
Dim xInterval As Integer
Dim xRows As Integer
Dim xRowsCount As Integer
Dim xNum1 As Integer
Dim xNum2 As Integer
Dim WorkRng As Range
Dim xWs As Worksheet
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
xRowsCount = WorkRng.Rows.Count
xInterval = Application.InputBox("Enter row interval. ", xTitleId, 1, Type:=1)
xRows = Application.InputBox("How many rows to insert at each interval? ", xTitleId, 1, Type:=1)
xNum1 = WorkRng.Row + xInterval
xNum2 = xRows + xInterval
Set xWs = WorkRng.Parent
For i = 1 To Int(xRowsCount / xInterval)
    xWs.Range(xWs.Cells(xNum1, WorkRng.Column), xWs.Cells(xNum1 + xRows - 1, WorkRng.Column)).Select
    Application.Selection.EntireRow.Insert
    xNum1 = xNum1 + xNum2
Next
End Sub

Press F5 to run code

Correcting Hunched Shoulders From Working at Desk All Day

 

Quick post on this which I will update at a later date…

 

Take a muscle relaxant like Magnesium glycinate

All magnesium is good for relaxing tense muscles, but glycinate is the only form which won’t give you the trots in high doses. It can make you sleepy, so take it in the evenings.

 

Stretch your Chest

The easiest way to stretch your chest is against a door frame, take a look at the video below for some ideas

Band Exercises

Maintain or increase your range of movement with band exercises. You use it or lose it with flexibility.

 

Rear Delt Flyes

Perform slowly with a squeeze and hold at the top of the movement

 

Invest in a Foam Roller

Lacrosse or cricket balls are good too for getting into particularly tight spots.

 

Hip Flexor Stretches

If you have hunched shoulders, there is a good chance that you have tight hip flexors and a titled pelvis from sitting down all day.
Make sure to stretch your hip flexors every day!

The reverse hyper machine is also excellent for correcting poor posture. It decompresses the spine and promotes blood supply to the lower back. The motion of extending the hips is also good for poor posture which results from sitting down all day.

Redirects – Check All URLs end with a slash

When doing redirects, for a new site –

sometimes, when you crawl the old/current site you will find a few rogue URLs that start with http: not https: and don’t end with a backslash.

 

If you’re doing a find and replace job, to create the destination URLs, this can mess with your final URLs.

Search “http:” to ensure, that if applicable, all the final URLs use the correct http protocol

Then use the formula below, to check the all end with a backslash

 

=IF(RIGHT(A1,1)=”/”,TRUE,FALSE)

 

Excel_backslash_formula

Enlightenment on a budget

So you finally ‘woke up’, you can see through all the marketing, the consumerism and the general BS that drives most of the economy.
But rather than feeling liberated and freed, you’re stuck in this kind-of cynical and depressing middle-ground.

So next step, you start meditating and going to yoga class.  To take things to the next level you start researching online and hear about all the yoga retreats that you can attend, and even read about ayahuasca retreats tripadvisor.

Ayahuasca, if you haven’t heard, is a herbal ‘drink’ that is often used by indigenous tribes in Peru.  It has been touted by the likes of former CNN reporter Amber Lyons as a cure (for want of a better word) for mental health problems including anxiety.

As good as this sounds, unless you have a spare grand or two floating round in your savings account, a trip to Peru to speak to ‘Mother Ayahuasca’ is probably not on the cards.  Other ironically expensive Buddhist-treats including flotation tanks, are beyond the budget of many of us too. So if you can’t afford to buy into the ‘enlightenment industry’, what can you do?

Flotation Tanks
You can learn more about them by watching this documentary:

 

American comedian, and martial artist Joe Rogan has one is his basement.  But he’s rich, and I am not.

Here is an alternative, which I’ve found a lot more effective for sensory deprivation than a floatation tank. Although, you will look proper mental.

Listening to white noise on it’s own, with sound proof ear phones is enough on its own, to normally produce hallucinations etc, due to the impact of sensory deprivation. Add the weird white-eye-mask to this, and you’ll feel ‘bodyless’ in about 20 mins.

 

Ayahuasca
Whilst ‘Mother Ayahuasca’ possesses the female energy, San Pedro and Peyote cactuses posses the male. 

 

You can’t use San Pedro or Peyote in the UK 😦

You can however get an Easy Jet flight over to Amsterdam, and buy and use Peyote or San Pedro legally. I have never done this myself, so cannot tout for the quality etc of what you can buy, but do feel it necessary to emphasise the importance of site and setting at this point. Don’t use it in the cheapest hotel you can find in Amsterdam. I’d recommend reading up and making some enquiries on Reddit.

22 Things to Know for your First Day on a Building Site

Tips for new Construction Workers

Disclaimer – don’t actually do any of this stuff (but it is the kind of thing to expect on a building site)

1. Don’t worry about where you put anything. There is officially no official place to leave equipment; in fact, you’ll spend 60% of your time, running around looking for a bucket for mortar

2. If you worry about health and safety people will either presume you are a homosexual (not that there’s anything wrong with that) and/or some kind of snob. It is common for brickies to leave bricks for example, standing upright, on the edge of walls above you and it is also common practice to leave as much crap as possible, including packaging, broken bricks and cable ties strewn across the scaffolding for people to trip over

3. Say “f*cking” every other word

4. Establish yourself as the alpha male as soon as possible by being the first to take your top off at any glimpse of sunshine, and by shouting the loudest during the ‘banter’

5. Eat pies & pasties, smoke 20 cigarettes per break, and then tell the middle-class guy that his hemp protein powder is bad for him and going to destroy his kidneys. In fact, being a builder gives you superior knowledge and life-experience, so be sure to put across your strong opinions on nutrition, education and politics 🙂

6. If the boss tells you off, just say “I’m really sorry la, won’t do it again”. He will love you forever as most apprentices can not take feedback at all (feedback = getting a bollocking).

7. Lift exclusively with your back.  People who lift with their legs are also presumed a ‘posh bellend’

www.cafepress.co.uk

8. At break, talk about how hard your mates are, and smoke just inside the door of the portacabin to ensure that it is completely ‘hotboxed’ with tobacco.
It’s important that you are seen either smoking, or using a gambling app on your phone.

9. If you don’t smoke, it is assumed that you are some kind of shifty bugger

10. Never ask anyone’s name, or introduce yourself; it’s just not done.  Call the person “la” and “mate” until you know their life story and it’s too awkward to ask their name

11. If the boss ever has to go off site somewhere, stop all work immediately

12. Once you are an established brickie, it is important to remove your hard-hat whenever the site manager is out of sight

13. Try and pretend you’re interested when the older brickies tell you stories about hod carrying, and saying stuff like “when I was your age…” and “you don’t know you’re born kid”; whatever that means

brick1

14. Pay someone to spread a rumour that you once killed a gorilla with an uppercut. Or something similar.  This will make you less of a target for pranks and the high-brow banter

15. Stop watching documentaries and QI, and make sure your ‘read’ the Daily Sport and Star, just so you can hold a conversation with one of your associates. It is crucial that you hold aggressive right-wing opinions that are reliably informed by tabloid newspapers.

16. Be grateful for being given a chance.  Many people, in many types of work, never get chance to put their qualifications into practice

17. “Bucket of sh!te” = bucket of mortar

18. Energy drinks are compulsory for under 35s. If you don’t have an energy drink and 5 cigarettes in the morning, you’ll be deemed an outsider.

'Hank, can I level with you'

19. “Customer Service” is not a known term. Once the job’s done, it’s done.

20. Always rub your chin 3 times before quoting a price

21. Aggression is the go-to emotional state for any good tradesman, whenever conflict, misunderstanding or frustration occur. The more aggressive you are, the better tradesman you become

22. Passing the buck is an art form on the building site. Just don’t expect anyone to know what ‘passing the buck’ actually means.

A poem about the great men of the building site

O brickie oh brickie what will it be?
A tea with 3 sugars plus an extortionate fee,
A red bull with 5 fags is the fuel that we need, to lay those bricks 4 u at an exceptional speed,
Ale for us, no yoga or weed,
6 pints in town, its the way that we breed.

Cash in hand for our holiday in the sun,
No receipt 4 u tho its not how its done.
Customer service is our number 1 aim,
But if anything goes wrong, its the previous workman that’s ta blame

builder

Baba Sling Review

Pro’s 
– Very quick to put on
– Support at the top for baby’s neck
– Attractive design (!?)
– You can breastfeed in it – although you do need one hand to support baby whilst you’re breastfeeding
– Convenient – nipping out, or driving somewhere and then nipping into the shops – quicker than a pram
– Close to your chest so baby feels secure and happy
– Good for attachment parenting

Con’s
– Weight is ‘across’ so not 100% evenly balanced
– Have to be mindful baby doesn’t slip down – small risk of suffocation

Baba Sling - great for breastfeeding
Baba Sling – great for breastfeeding!

 

Things to do for Free – Night Walks

I think it’s important to find things that are fun, that you can do for free.

If you don’t mind the risk of getting arrested, or attacked by a bear, then night-walking is awesome. Especially in the woods, on a clear night.  Unfortunately, on the video, I couldn’t get the sky to ‘show up’ nor the moon-light that was on the river.

Trust me though, it’s amazingly peaceful and a cool thing to do. It’s help if you have a dog so that you don’t look like a complete weirdo, and a head-torch.  Picking up poo in the dark can be a bit of a challenge too!

You can make it a cool meditation-esk practice too, by focusing on the sounds you can hear for 10 seconds, then focus on what you can see, and finally what you can feel – e.g. the wind on your face, breathing, feet on the floor etc.