Home › Forums › General Issues › Page link to taxonomy / category page
I remembered I made a awesome mega menu with acf, but it stopped at “adding a category as a menu item”.

Hi all,
@twgerard is having some issues posting a reply and has asked me to pass on the following:
Here is a link to the repository:
https://github.com/TWGerard/acf-anything-link
Thanks
Elliot
This plugin no longer works with the new ACF.
Is there a straight forward fix @elliot
https://github.com/TWGerard/acf-anything-link/issues/1
I have done an adaptation on the solution given by John Huebner on this issue:
https://support.advancedcustomfields.com/forums/topic/user-list-in-a-select-field/
add_filter('acf/load_field/name=referente_a_categoria', 'populateCategories');
function populateCategories( $field ){
// reset choices
$field['choices'] = array();
$hiterms = get_terms("product_cat", array("orderby" => "slug", "hide_empty" => false ));
foreach($hiterms as $key => $hiterm) :
$field['choices'][ get_term_link( $hiterm ) ] = $hiterm->name;
endforeach;
return $field;
}
Has anyone found a solution to this? Does the plugin @twgerard created no longer work?
+1 on this being a built-in
Some use cases:
– blog category archive pages
– woo product category archive pages
– woo product tag archive pages
Hi All,
This can be done as follows:
Field Type: Taxonomy
Taxonomy: Select your category
Appearance: Select
Return Value: Term Object (not Term ID)
Here’s how to display it on your Theme:
<?php $cat_link_term = get_field( 'my_category_url' ); ?>
<?php if ( $cat_link_term ): ?>
<a href="<?php bloginfo('url'); ?>/<?php echo $cat_link_term->slug; ?>"><?php echo $cat_link_term->name; ?></a>
<?php endif; ?>
Here’s how to us it within a repeater:
<?php while(the_repeater_field('my_category_repeater')) { ?>
<?php $cat_link_term = get_sub_field( 'my_category_url' ); ?>
<?php if ( $cat_link_term ): ?>
<a href="<?php bloginfo('url'); ?>/<?php echo $cat_link_term->slug; ?>"><?php echo $cat_link_term->name; ?></a>
<?php endif; ?>
<?php } ?>
Thanks,
Lee.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.