I love the page-link field type. The UI is perfect for CMS work. However, I have an issue. I’d like to be able to link to category / taxonomy archive pages – for instance http://example.com/my-category/.
Wordpress uses the template file taxonomy-slug.php, so each category can have an archive page.
What’s the best way to achieve this in ACF? I’d rather not just use a text field and rely on our users to correctly copy and paste the permalink.
Unfortunately, at the moment, a text field will be your best bet.
That or creating a new field type which includes the archive URLs you seek.
If you feel up to creating a new field type, there is plenty of docs and even a starter field template file to get you started over on the docs page!
any update on this? I was confused as the documentation shows that you can choose from Archives pages, but my Page Link does not ever show me archives… am I doing it wrong? (ACF Pro)
+1 on this, but in the mean-time, I’ve created a workaround. Simply use a “Taxonomy” as a select or radio (single value) field, and to get a link to that taxonomy archive, use:
get_category_link( get_field( 'your-taxonomy-field' ) )
for example, I used it in this way:
printf( '<a href="%1$s">Your Category</a>', get_category_link( get_field( 'your-taxonomy-field' ) ) );
The topic ‘Page link to taxonomy / category page’ 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!
© 2022 Advanced Custom Fields.