xarxaprod-wp-theme/template-parts/section-list-checkbox.php

37 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2024-01-09 16:13:20 +01:00
<?php
/**
* Template part for displaying a list with data checked in checkbox list
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Xarxaprod_theme
2024-01-09 16:13:20 +01:00
*/
?>
<?php
// https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130
// to display this template use
// 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'];
?>
2024-01-09 16:13:20 +01:00
<?php
$fields= get_field($fielditerate);
if( $fields ):
?>
<ul class="xarxaprod-label item-<?php echo $fielditerate ?>">
2024-01-09 16:13:20 +01:00
<?php foreach( $fields as $field ): ?>
<li>
<a href="<?php echo home_url( '/'. $current_post_type_slug . '/?' . $fielditerate . '='. $field['value'] ); ?>">
<?php echo $field['label']; ?>
</a>
2024-01-09 16:13:20 +01:00
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>