This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate-overzicht-tipgevers.php
69 lines (50 loc) · 1.71 KB
/
template-overzicht-tipgevers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Template Name: Overzichtspagina tipgevers
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
$context = Timber::context();
$timber_post = new Timber\Post();
$context['post'] = $timber_post;
if ( get_field( 'overzichtspagina_inleiding' ) ) {
// ACF veld 'post_inleiding' is gevuld
$intro = get_field( 'overzichtspagina_inleiding' );
$context['intro'] = wpautop( $intro );
}
$context['tipgevers'] = tipgevers_get_data();
Timber::render( [ 'template-alle-tips.twig', 'page.twig' ], $context );
function tipgevers_get_data() {
global $post;
$return = array();
if ( 'showsome' === get_field( 'overzichtspagina_showall_or_select', get_the_id() ) ) {
$terms = get_field( 'overzichtspagina_kies_items', get_the_id() );
} else {
$terms = get_terms( array(
'taxonomy' => OD_CITAATAUTEUR,
'hide_empty' => true,
) );
}
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
$item = [];
$item['title'] = $term->name;
$item['function'] = wp_strip_all_tags( get_field( 'tipgever_functietitel', $term ) );
$image = get_field( 'tipgever_foto', $term );
$item['url'] = get_term_link( $term );
$item['img_alt'] = sprintf( _x( 'Link to tips from %s', 'Arialabel image-link', 'gctheme' ), $item['title'] );
if ( $image ):
$size = 'thumbnail';
$item['img'] = $image['sizes'][ $size ];
endif;
$return['items'][] = $item;
}
}
if ( $return['items'] ) {
$return['title'] = get_field( 'downloads_title' ) ? get_field( 'downloads_title' ) : _x( 'Downloads', 'Titel boven downloads', 'gctheme' );
$return['desc'] = get_field( 'downloads_description' );
}
return $return;
}