-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathplantilla-distribuidora-01-auto.php
More file actions
40 lines (34 loc) · 1.02 KB
/
plantilla-distribuidora-01-auto.php
File metadata and controls
40 lines (34 loc) · 1.02 KB
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
<?php
/**
* Template Name: Distribuïdora automàtica amb blocs verticals
*
* @package wp-softcatala
*/
$context = Timber::context();
$post = Timber::get_post();
$context['post'] = $post;
$all_children = get_posts(
array(
'post_type' => 'page',
'post_parent' => $post->ID,
'orderby' => 'menu_order',
'order' => 'asc',
'posts_per_page' => - 1
)
);
$context['links'] = array_map( function ( $post ) {
$thumb_id = get_post_thumbnail_id( $post );
if ( $thumb_id ) {
$thumb_url = wp_get_attachment_image_src( $thumb_id, 'thumbnail-size', true );
$image_url = $thumb_url[0];
} else {
$image_url = get_template_directory_uri() . '/static/images/content/generic_image_bloc.png';
}
return array(
'internal_link' => get_permalink( $post ),
'titol' => get_the_title( $post ),
'imatge' => $image_url,
'descripcio' => get_post_field( 'post_excerpt', $post )
);
}, $all_children );
Timber::render( array( 'plantilla-distribuidora-01.twig' ), $context );