This repository has been archived on 2022-08-01. You can view files and clone it, but cannot push or open issues or pull requests.
Oldphaloskepsis/taxonomy-company.php

1 line
7.9 KiB
PHP
Raw Normal View History

2017-05-25 18:57:33 +00:00
<?php /** * The template for displaying archive pages * * Used to display archive-type pages if nothing more specific matches a query. * For example, puts together date-based pages if no date.php file exists. * * If you'd like to further customize these archive views, you may create a * new template file for each one. For example, tag.php (Tag archives), * category.php (Category archives), author.php (Author archives), etc. * * @link https://codex.wordpress.org/Template_Hierarchy * * @package WordPress * @subpackage Twenty_Sixteen * @since Twenty Sixteen 1.0 */ get_header(); ?> <?php $i = 0; function withinDates($jSDate, $jEDate) { //$endYear = date( "Y" ); $endDate = strtotime(date('Y-m-d')); $startDate = strtotime("2015-01-01"); $jSDate = strtotime($jSDate); if ($jEDate) { $jEDate = strtotime($jEDate); $jEDate = ($jEDate < $endDate) ? $jEDate : $endDate; } else $jEDate = strtotime(date('Y-m-d')); return (($jSDate < $endDate) && ($jEDate > $startDate)); } $company = get_queried_object(); $args= array( 'post_type' => array( 'job' ), 'tax_query' => array( array( 'taxonomy' => 'company', 'field' => 'slug', 'terms' => $company->name, ), ), 'posts_per_page' => -1 ); $loop = new WP_Query( $args ) ?> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['timeline']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var container = document.getElementById('timeline'); var chart = new google.visualization.Timeline(container); var dataTable = new google.visualization.DataTable(); dataTable.addColumn({ type: 'string', id: 'Type' }); dataTable.addColumn({ type: 'string', id: 'Job Title' }); dataTable.addColumn({ type: 'date', id: 'Start' }); dataTable.addColumn({ type: 'date', id: 'End' }); dataTable.addRows([ <?php while ( $loop->have_posts() ) : $loop->the_post(); //if (withinDates(get_the_date(), get_post_meta(get_the_ID(), 'end-date', true))) { $companies = wp_get_object_terms(get_the_ID(), 'company'); $i = 0; $currSizeOf = -1; foreach ($companies as $company) { if (sizeof(get_ancestors($company->term_id, 'company')) > $currSizeOf) { $currSizeOf = sizeof(get_ancestors($company->term_id, 'company')); $lowestDepthCompany = $i++; } } $title = html_entity_decode(get_the_title()); $start = get_the_date(); $end = (!get_post_meta(get_the_ID(), 'end-date', true)) ? date('D M d Y H:i:s O') : get_post_meta(get_the_ID(), 'end-date', true); echo "[ '{$companies[$lowestDepthCompany]->name}', '$title', new Date('$start'), new Date('$end') ],\n"; //} endwhile; ?> ]); chart.draw(dataTable); var realheight=parseInt($("#timeline div:first-child div:first-child div:first-child div svg").attr( "height"))+50; options.height=realheight; //$("#timeline").attr("height", realHeight); chart.draw(dataTable, options); } </script> <div id="primary" class="content-area"> <?php print apply_filters( 'taxonomy-images-queried-term-image', '', array( 'attr' => array( 'alt' => get_queried_object()->name.' logo', 'class' => 'taxonomy-background', ), 'before' => '<div class="taxonomy-background-container" style="background-color: '.get_term_meta(get_queried_object()->term_id, 'color')[0].';">', 'after' => '</div>', 'image_size' => 'full' ) ); ?> <main id="company-main"