I’m having trouble wrapping my head around how to link images to categories (slugs). The goal is to create a page with category images. I’ve searched the documentation and forums, but couldn’t find exactly what I was looking for, unless I missed it? If you know where I can find the documentation, would appreciate a link to the page.
I’ve tried messing with the Taxonomy Field (along with the Image field), but couldn’t get that to work as a link (image would link to a number, but it didn’t go anywhere).
So I went back to trying the WYSIWYG field and was going to try linking using the Image Alt somehow, but I can’t figure out how to do that. I just need to make this as simple as possible for the client to use, and still give them the control to keep them organized the way they want to.
I’m open to ideas of course. Help??
The easiest way to do this is to create a field group which contains the image field, and use the location rules to attach this field group to the taxonomy you want.
Now when you edit the taxonomy term you will be able to add an image. Thus associating an image with each term (cagtegory).
A page that shows all the taxonomies? That sounds like a taxonomy archive page and you can read about these on google / wp.org
I’m sorry, I have no idea what you’re trying to tell me LOL!
Does anyone have an answer to this one yet? It’s probably something simple, but I have no idea to go about it because there is no documentation for this particular thing here, no example code, nothing. I just need to know what code and what fields to use and I don’t have time for reading tutorials on the internet, I’m kind of on a tight schedule. If there was documentation for this stuff on this site, I wouldn’t be asking in the forums 😉
Sorry, let me paste what I wrote up there:
“there is no documentation for this particular thing here, no example code”
What I mean is there’s no documentation for what I’m trying to accomplish. I did review the documentation that is available and tried using that to create a link to the category, as I mentioned in my original post:
“I’ve tried messing with the Taxonomy Field (along with the Image field), but couldn’t get that to work as a link (image would link to a number, but it didn’t go anywhere).”
You need to break your task up into easy to tackle stages.
1. Create a field group for the taxonomy, and add an image field.
2. Edit your taxonomies and add the image data for each
3. Create a custom page template an give it a name such as ‘Taxonomy Thumbnails’
4. Create a page in the CMS and use this page template. View the page to see a blank white screen.
5. Search on WP how to get all the taxonomy terms and loop through them. There is lots of documentation for this on the web.
6. Finally, within the taxonomy loop, use the term_id to load in the ACF image data and render the image!
7. Pop open a beer!
What I’m having trouble with is the code to use. ACF code.
Here’s what I tried that’s not working:
<?php if ( get_post_meta($post->ID, 'my_image', true) ) : ?> <a href="<?php if ( get_post_meta($post->ID, 'my_image_link', true) ) : ?>"><img src="<?php the_field('my_image'); ?>" /></a> <?php endif; ?>
This is what I’m having trouble with. When I add the ACF code to load the Taxonomy (which should be converted to a link, since the ACF Link field isn’t working for some reason) I’m not getting a real link, I’m getting a link to a number that goes nowhere.
Sorry mate. Your code contains too make syntax and PHP errors for me to help on this one.
I would advise you to read over the documentation for the image field to find out how it works.
1. Use get_field
2. Address the if statement inside your img src
3. Correct the field names
4. Correct the field return types
5. Your code has no reference to anything taxonomy related
Kind of my point really, I’m not a programmer. I design custom templates, but I don’t do any custom coding. If there’s no example, I’m at a loss.
oh well, I’m sure there’s someone out there that knows how to code php and uses ACF, I’ll check wp forums. Thanks anyway.
The topic ‘Category Links’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.