Hello, i found this code for show all choice values
<?php
$field = get_field_object('field_name');
if( $field['choices'] ): ?>
<ul>
<?php foreach( $field['choices'] as $value => $label ): ?>
<li><?php echo $label; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
but I need to wrap each value in a link, when you click on it, you will be taken to a page with an arbitrary post type containing the selected value
Just amend the HTML to include the $label in the a tag:
<?php
$field = get_field_object('field_name');
if( $field['choices'] ): ?>
<ul>
<?php foreach( $field['choices'] as $value => $label ): ?>
<li><a href="<?php echo $label; ?>"><?php echo $label; ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Thanks, but when i click to link i have 404 error
What does $label output?
How have you got the field setup?
What data are you entering?
the value of the checkbox type field
I have a checkbox type field with values: type1, type2, type3 and etc.
On custom post type archive page i want to show all values with links, on a page I want to output all field values with a link. When you click on the value link, open a page with posts that contain the selected value
Please re-read what I asked for and reply