oficinasuport-wp-theme/archive-ofisuport-ajut.php

107 lines
3.5 KiB
PHP

<?php
/**
* The template for displaying archive custom post type ajut
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Oficina_de_Suport_theme
*/
get_header();
?>
<main id="primary" class="site-main">
<section id="filteredfunds" class="ofisuport-filtered-funds ofisuport-ajuts-filtrats">
<aside id="fundsfilter" class="ofisuport-filter-funds ofisuport-fitre-ajuts">
<div id="arhive-filters" class="ofisuport-filters">
<?php
// output all possible values of a checkbox
$groupkey = "group_63ab636898703"; // write here the key for the group of fields from acf
if( $groupkey){
//echo '<h6>check the groupkey <span style="color: #00b">' . $groupkey . '</span></h6>';
$groupkey_fields = acf_get_fields($groupkey);
foreach( $groupkey_fields as $field_key ) {
if( $field_key['type'] == 'checkbox' ){
//echo '<span style="color: #00b">' . ($field_key['key']) . '</span><br/>';
//echo '<span style="color: #00b">' . ($field_key['label']) . '</span><br/>';
//echo '<span style="color: #00b">' . ($field_key['name']) . '</span><br/>';
// https://wordpress.stackexchange.com/a/102915
//$field_key = "field_XXXXXX";// the acf field key unic numbers
$field_key = $field_key['key'];
$fields = get_field_object($field_key);
if( $fields )
{
// check for values in url
foreach( $GLOBALS['my_query_filters'] as $key => $fieldname ):
// set value if available
if( isset($_GET[ $fieldname ]) ) {
$filteredvalues['value'] = explode(',', $_GET[ $fieldname ]);
};
// construct the checkboxes
if( $fieldname == $fields['name']) {
echo '<nav id="fund-filter" class="ofisuport-filter ' . $fields['name'] . '">' ;
echo '<h5>' . $fields['label'] . '</h5>';
echo '<ul>';
foreach( $fields['choices'] as $choicevalue => $choicelabel ) {
echo '<li>';
echo '<input type="checkbox" ';
echo ' value="' . $choicevalue . '" ';
if( in_array($choicevalue,$filteredvalues['value']) ):
echo ' checked="checked" ';
endif;
echo ' />';
echo $choicelabel;
echo '</li>';
}
echo '</ul>';
echo '</nav>';
};
// end of construct checkboxes
endforeach;
// end check for values in url
}
};//end if type checkbox
};//end foreach groupkey field
};//end if groupkey
?>
<?php //endforeach; ?>
</div>
</aside>
<content class="archive-posts <?php ofisuport_class_posttype(); ?>">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post();
get_template_part( 'template-parts/section', 'eachpost' );
endwhile;
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
</content>
</section>
</main><!-- #main -->
<?php
get_footer();