created links for the acf labels and fields so they can be followed

This commit is contained in:
jorge 2024-02-25 16:57:13 +01:00
parent d65bfb35d3
commit b083e86d79
2 changed files with 36 additions and 2 deletions

View File

@ -97,6 +97,34 @@
<?php get_template_part( 'template-parts/section', 'list-checkbox', array('iterate_field' => 'xxp_convo_center') ); ?>
</div>
<?php if( get_field('xxp_convo_espai_associat') ): ?>
<div class="xarxaprod-convo-espai-associat">
<h6>Espai Associat</h6>
<?php
// read here howto
// https://www.advancedcustomfields.com/resources/relationship/#display-list-of-posts-with-setuppostdata
$espai_associat_posts = get_field('xxp_convo_espai_associat');
if( $espai_associat_posts ): ?>
<ul class="xarxaprod-label item-<?php echo $espai_associat_posts; ?>">
<?php foreach( $espai_associat_posts as $post ):
// Setup this post for WP functions (variable must be named $post).
setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php
// Reset the global post object so that the rest of the page works correctly.
wp_reset_postdata(); ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="xarxaprod-convo-info-field">
<h6>Termini</h6>
<?php if( get_field('xxp_convo_apply_begin') || get_field('xxp_convo_apply_end') ): ?>

View File

@ -15,7 +15,11 @@
// get_template_part( 'template-parts/section', 'list-checkbox', array('iterate_field' => 'CHANGETHIS') );
$fielditerate = $args['iterate_field'];
?>
<?php
// get the current post-type slug
// https://wordpress.stackexchange.com/a/67412
$current_post_type_slug = get_post_type_object( get_post_type() )->rewrite['slug'];
?>
<?php
$fields= get_field($fielditerate);
if( $fields ):
@ -23,7 +27,9 @@
<ul class="xarxaprod-label item-<?php echo $fielditerate ?>">
<?php foreach( $fields as $field ): ?>
<li>
<a href="<?php echo home_url( '/'. $current_post_type_slug . '/?' . $fielditerate . '='. $field['value'] ); ?>">
<?php echo $field['label']; ?>
</a>
</li>
<?php endforeach; ?>
</ul>