I have a custom field called “Course ID”.
I have Woocommerce installed. In permalinks, under product permalinks, I have “/courses/%product_cat%”.
I was wondering if it was possible to do something like “/courses/%product_cat%-%course_id%” or some way to add the course ID to the permalink.
First you would need to figure out how to change the output of the link wherever WC is outputting it. Then you’d need to alter the WP rewrite rules for your site, especially since you are talking about altering a taxonomy term url. All could be possible with a large amount of work.
Alternately, you could create an acf/save_post filter, see if what is being saved is a term in your taxonomy and then alter the term slug every time that the term is saved. Also a possible solution and more likely that the first one. Still a little complicated and I don’t know the exact details of getting it done.
I’m using woocommerce to set up courses.
The courses available are for Grade 11 and Grade 12 students.
English, for example, is part of both categories and looks like this:
I’m trying to figure out a way to deal with this, I was thinking, because I already have a field that gets the course’s code, that I could use acf to modify the url to look like this:
I could do this manually in the post’s slug, but I was thinking it would be neat if it were dynamic somehow.
You cannot make permalinks like this and mix “/“, “–” without heavy PHP magic.
/grade-11/english to /grade-11/english-eng3u. Your field value (all of them) would need to have this sign “-“.
You dont have so many language courses ? Even theoretically it they are in hundreds WordPress now manages Terms well. As long you dont use to many Select (dropdown) options Terms on shared hosting.
Do it like this:
– “grade 11” = (you use WooCommerce) Products main Category/Taxonomy/Term.
– “english” = subcategory/Term of “grade11” main category.
– “eng3u” = sub category/Term of “english” subcategory.
Just simple nested categories and Terms. This is very reusable everywhere in WordPress for future website building, not like using fields. And Permalinks are generated naturally, no tweaks needed.
Hello @darrenbachan .
You can use any custom post field generated by ACF plugin in URL permalink structure thanks to the plugin:
Moreover, you can create dynamic values based on that fields:
The topic ‘How to add field value to permalink?’ 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!