$search_args = get_post_query_args('esdeveniment', SearchQueryType::Search, $search); $args = wp_parse_args($search_args, $wp_query->query); //search + active args $date_filter_args = get_post_query_args('esdeveniment', SearchQueryType::FilteredDate, $filterdate); $args = wp_parse_args($date_filter_args, $args); //all filters applied $date_filter_args = get_post_query_args('esdeveniment', SearchQueryType::FilteredTema, $tema); $args = wp_parse_args($date_filter_args, $args); //all filters applied $context_holder['selected_filter_tema'] = $tema; $context_holder['selected_filter_data'] = $filter; $context_holder['cerca'] = $search; $title = 'Esdeveniments - '; !empty($search) ? $title .= 'cerca: ' . $search . ' - ' : ''; !empty($tema) ? $title .= 'tema: ' . get_term_name_by_slug($tema, 'esdeveniment_cat') . ' - ' : ''; !empty($filter) ? $title .= 'data: ' . get_the_filter_date_name($filter) . ' - ' : ''; $title .= 'Softcatalà'; } else { $title = 'Esdeveniments - Softcatalà'; $description = 'Esdeveniments relacionats amb el món de la tecnologia i el català.'; $args = $wp_query->query; } //Posts and pagination query_posts($args); $context_holder['posts'] = Timber::get_posts($args); $context_holder['pagination'] = Timber::get_pagination(); //Context initialization $context_filterer = new SC_ContextFilterer($context_holder); $context_overrides = array('title' => $title, 'description' => $description); $context = $context_filterer->get_filtered_context($context_overrides, false); Timber::render($templates, $context);
* @package wp-softcatala */ //JS and Styles related to the page wp_enqueue_script('sc-js-steps', get_template_directory_uri() . '/static/js/steps.js', array('sc-js-main'), WP_SOFTCATALA_VERSION, true); wp_localize_script('sc-js-steps', 'scajax', array('ajax_url' => admin_url('admin-ajax.php'))); //Template initialization $templates = array('plantilla-steps.twig'); //Project $project_slug = get_query_var('project'); if (!empty($project_slug)) { $projecte = get_page_by_path($project_slug, OBJECT, 'projecte'); $projecte = new TimberPost($projecte->ID); $content_title = 'Col·laboreu en el projecte ' . $projecte->post_title; $projecte->project_requirements = apply_filters('the_content', $projecte->project_requirements); $projecte->lectures_recomanades = apply_filters('the_content', $projecte->lectures_recomanades); $context_filterer = new SC_ContextFilterer(); $context = $context_filterer->get_filtered_context(array('title' => $content_title . '| Softcatalà')); $context['projecte'] = $projecte; $context['steps'] = $projecte->get_field('steps'); $templates = array('plantilla-steps-single.twig'); $args = array('meta_query' => array(get_meta_query_value('projectes', $projecte->ID, 'like', ''))); $context['membres'] = get_users($args); } else { $post = Timber::get_post(); $profile = $post->get_field('perfil'); $profile_label = get_field_object('perfil', $post->ID); $all_acf_data = get_field_objects($post->ID); $content_title = 'Col·laboreu amb nosaltres: ' . $profile_label['choices'][$profile]; if (false === $profile || empty($profile)) { wp_redirect('/col·laboreu/', 302); }
<?php /** * Archive page for programa custom post type * * Methods for TimberHelper can be found in the /lib sub-directory * * @package wp-softcatala */ //JS and Styles related to the page //Template initialization $templates = array('archive-projecte.twig'); $post = retrieve_page_data('projecte'); $post ? $context['links'] = $post->get_field('link') : ''; $title = 'En què treballem: ' . single_term_title('', false); $contextFilterer = new SC_ContextFilterer(); $context = $contextFilterer->get_filtered_context(array('title' => $title)); $context['post'] = $post; $context['content_title'] = $title; $context['post_type'] = $post_type; $context['sidebar_top'] = Timber::get_widgets('sidebar_top'); $context['sidebar_bottom'] = Timber::get_widgets('sidebar_bottom'); $context['sidebar_elements'] = array('static/suggeriment.twig', 'baixades.twig', 'links.twig'); //Posts and pagination $args = $wp_query->query; $context['posts'] = $sc_types['projectes']->get_sorted_projects($args); $context['pagination'] = Timber::get_pagination(); Timber::render($templates, $context);
<?php /** * Template Name: Subpàgina Projecte * * @package wp-softcatala */ $post_subpagina = new TimberPost(); $post = new TimberPost($post_subpagina->projecte); $context_filter = new SC_ContextFilterer(); $context = $context_filter->get_filtered_context(array('prefix_title' => $post->title)); $context['sidebar_top'] = Timber::get_widgets('sidebar_top'); $context['sidebar_elements'] = array('static/dubte_forum.twig', 'baixades.twig', 'links.twig'); $context['sidebar_bottom'] = Timber::get_widgets('sidebar_bottom'); $context['post_subpagina'] = $post_subpagina; $context['post'] = $post; $context['current_url'] = get_current_url(); $logo = get_img_from_id($post->logotip); $context['logotip'] = $logo; $custom_logo_filter = function ($img) use($logo) { return $logo; }; add_filter('wpseo_twitter_image', $custom_logo_filter); add_filter('wpseo_opengraph_image', $custom_logo_filter); $context['links'] = $post->get_field('link'); $context['credits'] = $post->get_field('credit'); if (is_array($post->responsable)) { $context['responsables'] = get_users_metadata($post->responsable); } else { $context['responsables'] = false; }