Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Aaron HARPT
Aaron HARPT
19,845 Points

Wordpress image function

I am currently having an issue with my Wordpress theme. The client is wanting the ability to add/remove images on their own (using the admin area). What function do I need to add in my page templates to allow him to accomplish this?

Aaron

3 Answers

Jonny Noble
Jonny Noble
11,165 Points

Check out a plug in for WordPress called Advanced Cudtom Fields. There's plenty of info in regards to galleries and images.

To coattail here, yes, this is the plugin you wan to use, if the images are part of a gallery or a "repeatable" field you will need to use ACF pro version, and use the repeater field to add that functionality.

Aaron HARPT
Aaron HARPT
19,845 Points

Thanks. Is the easiest way to add a new image going into the "Custom Fields" section of the admin area and adding a new field group? I am thinking that process may be a little too involved for my client. Is there an easier way?

Aaron

I think it's best you review the docs for ACF, and see if its a good fit for you and your client. If you want the easiest option for wordpress and images, there is the wordpress images gallery built into wordpress, but I don't recommend using it.

here are the docs for ACF

side note, please note that under the license of ACF you cannot charge your client for the cost of the plugin. Just FYI

Jonny Noble
Jonny Noble
11,165 Points

When you create the field itself you will have to specify where the image will go. Will it be on a page template, on the main index page or in the single blog post? If it's going to be on a page template you will have to select page template then default template for example. Then navigate to the page(s) that are using the default template then the image field should be there. There are code snippets in the advanced custom fields web pages so search for acf image then copy and paste whichever code you need.

I find this is the easiest way to add the images.

As Jacob mentioned the pro version of acf is good. If your client required multiple images you could use a repeater field but the only downside is that the plug in is a little more expensive, however, the plug in pretty much pays for itself due to its ease of use.