Commit bea251ab authored by Simonas's avatar Simonas

Search & meta tags complete

parent 0110623c
<?php
/**
* Template Name: Jobs listing
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Biuro
* @since 1.0
* @version 1.0
*/
get_header(); ?>
<?php
while ( have_posts() ) :
the_post();
the_content();
endwhile;
?>
<?php
// global $query_string;
// wp_parse_str( $query_string, $search_query );
// $search = new WP_Query( $search_query );
// debug( $query_string );
// debug( $search_query );
// debug( $search );
$ID = get_the_ID();
$keys = get_post_custom_keys();
// $where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '"';
$where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '" AND (t.post_title LIKE "%' . searchQuery . '%" OR t.post_content LIKE "%' . searchQuery . '%")';
$taxonomies = array();
foreach ( $keys as $key => $value ) {
$val = trim($value);
$taxonomy = substr($val, 20);
if ( '_' == $val{0} || substr($val, 0, 20) != 'built_in_taxonomies_' || !$taxonomy):
continue;
endif;
$res = get_post_custom_values( $val, $ID );
if ( !$res ) {
continue;
}
$term = $res[0];
if ( !$term ) {
continue;
}
$where = $where . ' AND ' . $taxonomy . '.slug = "' . $term . '"';
}
$params = array(
'orderby' => 'date DESC',
'where' => $where,
'limit' => 21
);
$jobs = pods( 'job', $params );
if ( 0 < $jobs->total() ):
get_template_part( 'template-parts/jobs/jobs', 'list' );
else:
get_template_part( 'template-parts/jobs/jobs', 'not-found' );
endif;
?>
<?php get_footer();
:root{--color--gray:#4d4d4d;--color--green:#006957;--typo--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI Light","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;--typo--font-size:1.8rem;--typo--weight-slim:100;--typo--weight-regular:400;--typo--weight-bold:600;--typo--line-height:1.2;--typo--font-face:"PT Sans Narrow",sans-serif;--typo--font-face-additional:"Bebas Neue",sans-serif;--layout-width:63em}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}html{-webkit-box-sizing:border-box;box-sizing:border-box}*,:after,:before{-webkit-box-sizing:inherit;box-sizing:inherit}a,body{color:#4d4d4d;color:var(--color--gray)}body{font-size:1.8rem;font-size:var(--typo--font-size);line-height:1.2;line-height:var(--typo--line-height)}html{min-height:100%;font-size:62.5%;-webkit-tap-highlight-color:rgba(0,0,0,0)}.l-content,.l-footer,.l-header,.l-inner{max-width:63em;max-width:var(--layout-width);margin-right:auto;margin-left:auto;padding-right:1em;padding-left:1em}.l-header{padding-top:15px;padding-bottom:15px}.o-nav{margin:0;padding:0;list-style:none}.c-cookies-warning{display:none}.c-data-controller{padding:0 1em;text-align:center;font-size:88%}.c-data-controller p{margin-bottom:0}.c-jobs-list{width:100%;margin:0 0 20px}.c-jobs-list--head{padding:10px}.c-jobs-list--col{padding:0 10px}.c-logo--svg{display:block}.c-nav--main{display:-webkit-box;display:-ms-flexbox;display:flex}.c-nav--sub,.u-hidden{display:none}@media (min-width:48em){:root{--typo--font-size:1.6rem;--typo--line-height:1.3}body{font-family:PT Sans Narrow,sans-serif;font-family:var(--typo--font-face)}.l-header{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.l-content,.l-header{display:-webkit-box;display:-ms-flexbox;display:flex}.l-aside{-webkit-box-flex:0;-ms-flex:0 0 16.25em;flex:0 0 16.25em}.l-main,.l-nav{-webkit-box-flex:1;-ms-flex:1 1 100%;flex:1 1 100%}.c-nav--main{padding-left:2em}}@media (max-width:47.999em){body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI Light,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-family:var(--typo--font-family);letter-spacing:-.08rem}.c-nav--main{margin:20px 0}}@media (min-width:30em){.c-jobs-list--col{padding:10px}}@media (max-width:29.999em){.c-jobs-list--col-position{padding-top:10px}}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -100,6 +100,6 @@
endif;
?>
<script src="/wp-content/themes/biuro/js/main-32abb748.min.js" async></script>
<script src="/wp-content/themes/biuro/js/main.min.js" async></script>
</body>
</html>
......@@ -32,7 +32,6 @@
// https://pods.io/docs/code/pods/find/
$where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '"';
// $where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '" AND (t.post_title LIKE "%' . searchQuery . '%" OR t.post_content LIKE "%' . searchQuery . '%")';
$params = array(
'orderby' => 'date DESC',
......
......@@ -319,7 +319,7 @@ function getSiteTree($taxonomy)
'hide_empty' => false,
));
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ):
if ( !empty( $terms ) && ! is_wp_error( $terms ) ):
echo '<ul>';
foreach ( $terms as $term ):
......
......@@ -31,16 +31,16 @@ define('cityID', $cityID);
get_template_part( 'template-parts/meta/canonical');
?>
<style><?php include 'css/core-a25434ed1d.min.css'; ?></style>
<style><?php include 'css/core.min.css'; ?></style>
<link rel="preload" href="/wp-content/themes/biuro/css/main-04cee33275.min.css" as="style" onload="this.rel='stylesheet'">
<link rel="preload" href="/wp-content/themes/biuro/css/main.min.css" as="style" onload="this.rel='stylesheet'">
<link rel="preload" href="/wp-content/themes/biuro/fonts/pt_sans_narrow.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/wp-content/themes/biuro/fonts/pt_sans_narrow_bold.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/wp-content/themes/biuro/fonts/bebas-neue.woff2" as="font" type="font/woff2" crossorigin>
<noscript>
<link rel="stylesheet" href="/wp-content/themes/biuro/css/main-04cee33275.min.css">
<link rel="stylesheet" href="/wp-content/themes/biuro/css/main.min.css">
</noscript>
<?php wp_head(); ?>
......@@ -108,8 +108,6 @@ $section = get_post_meta( $post->ID, 'section', true );
<div id="main" class="l-content">
<?php
// if ( !is_front_page() && get_post_type() == 'page' && get_page_template_slug() == 'search.php' || is_search() ):
if ( get_page_template_slug() == 'search.php' || is_search() ):
?>
<aside class="l-aside">
......
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Biuro
* @since 1.0
* @version 1.0
*/
get_header(); ?>
<h1>index.php</h1>
<?php
if ( is_search() ):
?>
<?php
// Use for search
// https://pods.io/docs/code/pods/find/
// $where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '" AND t.post_title LIKE "%' . $searchQuery . '%"';
$where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '" AND (t.post_title LIKE "%' . searchQuery . '%" OR t.post_content LIKE "%' . searchQuery . '%")';
if (cityID):
$where = $where . ' AND city.term_id = ' . cityID;
endif;
$params = array(
'orderby' => 'date DESC',
'where' => $where,
'limit' => 21
);
$jobs = pods( 'job', $params );
if ( 0 < $jobs->total() ):
get_template_part( 'template-parts/jobs/jobs', 'list' );
else:
get_template_part( 'template-parts/jobs/jobs', 'not-found' );
endif;
?>
<?php
else:
?>
<?php
while ( have_posts() ) :
the_post();
the_content();
endwhile;
endif;
?>
<?php get_footer();
!function(e){var n={};function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(o,i,function(n){return e[n]}.bind(null,i));return o},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/",t(t.s=0)}([function(e,n,t){e.exports=t(1)},function(e,n,t){var o;!function(e){var n=document.getElementById("cookie-warning"),t=document.getElementById("cookie-agree"),o=document.getElementById("cookie-close"),i=!!r()&&localStorage.getItem("biuro-agree");function r(){try{return localStorage.setItem("a","a"),localStorage.removeItem("a"),!0}catch(e){return!1}}n&&t&&o&&!i&&(n.style.display="block",t.addEventListener("click",function(){r()&&localStorage.setItem("biuro-agree","true"),n.style.display="none"}),o.addEventListener("click",function(){n.style.display="none"}))}(window),window,(o=document.getElementById("js-divisions-map"))&&fetch("/wp-json/biuro-api/v1/divisions?lang="+o.dataset.lang).then(function(e){return e.json()}).then(function(e){!function e(n,t){if(window.google){var o=new window.google.maps.Map(n,{mapTypeId:window.google.maps.MapTypeId.ROADMAP});window.google.maps.event.addListenerOnce(o,"bounds_changed",function(){this.getZoom()>15&&this.setZoom(14)});var i=[],r=document.querySelector(".js-active-region"),a=r&&r.dataset.id?r.dataset.id:"";t[a]?i=t[a]:Object.keys(t).forEach(function(e){var n=t[e];"city"===e.substr(0,4)&&(i=i.concat(n))}),function(e,n){for(var t,o=new window.google.maps.LatLngBounds,i=0;i<n.length;i++){var r=n[i],a=new window.google.maps.LatLng(r.lat,r.lng),c=new window.google.maps.Marker({position:a,map:e,icon:"/wp-content/themes/biuro/i/maps/pin.png",title:r.title});o.extend(a),c.content=r.content,window.google.maps.event.addListener(c,"click",function(){t&&t.close(),(t=new window.google.maps.InfoWindow({content:this.content})).open(e,this)})}e.fitBounds(o)}(o,i.filter(function(e){return e.lat&&e.lng}))}else setTimeout(function(){e(n,t)},250)}(o,e)})}]);
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -105,14 +105,24 @@ get_header(); ?>
if ( $searchQuery ) :
if ( $searchQuery['city'] ) :
$where = $where . ' AND city.term_id = ' . $searchQuery['city'];
if ( $searchQuery['city'] && intval( $searchQuery['city'] ) ) :
$where = $where . ' AND city.term_id = ' . intval( $searchQuery['city'] );
endif;
if ( $searchQuery['s'] ) :
$where = $where . ' AND (t.post_title LIKE "%' . $searchQuery['s'] . '%" OR t.post_content LIKE "%' . $searchQuery['s'] . '%")';
endif;
$field = get_term_by( 'name', $searchQuery['s'], 'field' );
$type = get_term_by( 'name', $searchQuery['s'], 'type' );
if ( $field ) :
$where = $where . ' AND field.term_id = ' . $field->term_id;
elseif ( $type ) :
$where = $where . ' AND type.term_id = ' . $type->term_id;
else:
$where = $where . ' AND (t.post_title LIKE "%' . $searchQuery['s'] . '%" OR t.post_content LIKE "%' . $searchQuery['s'] . '%")';
endif;
endif;
endif;
// $where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '" AND (t.post_title LIKE "%' . $searchQuery . '%" OR t.post_content LIKE "%' . $searchQuery . '%")';
......
......@@ -70,20 +70,104 @@
<input list="search-cities" id="search-city" name="city" value="<?php echo cityID; ?>" placeholder="Vietovė" />
<datalist id="search-types">
<option value="Darbas užsienyje: Norvegijoje, Vokietijoje, UK ir kt.">Darbas užsienyje: Norvegijoje, Vokietijoje, UK ir kt.</option>
<option value="Darbas studentams">Darbas studentams</option>
<option value="Sezoninis darbas">Sezoninis darbas</option>
<option value="Darbas namuose">Darbas namuose</option>
<option value="Darbas vasarai">Darbas vasarai</option>
<option value="Papildomas darbas">Papildomas darbas</option>
<option value="Personalo specialistai">Personalo specialistai</option>
<option value="Elektonika">Elektonika</option>
<option value="Pardavimai">Pardavimai</option>
<option value="Gamyba">Gamyba</option>
<option value="Sandėliavimas">Sandėliavimas</option>
<option value="Klientų aptarnavimas">Klientų aptarnavimas</option>
<option value="Padavejai">Padavejai</option>
<?php
$options = array();
$types = get_terms( array(
'taxonomy' => 'type',
'orderby' => 'count',
'order' => 'DESC'
// 'orderby' => array(
// 'title' => 'DESC'
// // 'menu_order' => 'ASC'
// )
// 'hide_empty' => false,
));
if ( ! empty( $types ) && ! is_wp_error( $types ) ):
foreach ( $types as $type ):
$name = $type->name;
$termID = $type->term_id;
$selected = '';
// $selected = ($cityID == $termID) ? 'selected="selected"' : '';
$where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '" AND type.term_id = ' . $termID;
$params = array(
// 'orderby' => 'title DESC',
'where' => $where,
'limit' => -1
);
$jobsIn = pods( 'job', $params );
if ( 0 < $jobsIn->total() ):
array_push( $options , array( 'name' => $name, 'total' => $jobsIn->total() ) );
/*
?>
<option value="<?php echo $name; ?>"><?php echo $name; ?> (<?php echo $jobsIn->total(); ?>)</option>
<?php
*/
endif;
endforeach;
endif;
$fields = get_terms( array(
'taxonomy' => 'field',
'orderby' => 'count',
'order' => 'DESC'
// 'orderby' => array(
// 'title' => 'DESC'
// // 'menu_order' => 'ASC'
// )
// 'hide_empty' => false,
));
if ( ! empty( $fields ) && ! is_wp_error( $fields ) ):
foreach ( $fields as $field ):
$name = $field->name;
$termID = $field->term_id;
$selected = '';
// $selected = ($cityID == $termID) ? 'selected="selected"' : '';
$where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '" AND field.term_id = ' . $termID;
$params = array(
// 'orderby' => 'title DESC',
'where' => $where,
'limit' => -1
);
$jobsIn = pods( 'job', $params );
if ( 0 < $jobsIn->total() ):
array_push( $options , array( 'name' => $name, 'total' => $jobsIn->total() ) );
endif;
endforeach;
endif;
usort($options, function ($item1, $item2) {
return $item2['total'] <=> $item1['total'];
});
foreach ( $options as $option ):
?>
<option value="<?php echo $option['name']; ?>"><?php echo $option['name']; ?> (<?php echo $option['total']; ?>)</option>
<?php
endforeach;
?>
</datalist>
<?php
// debug( $options );
?>
<input list="search-types" id="search" name="s" value="<?php echo searchQuery; ?>" placeholder="Raktažodis" />
......
......@@ -12,6 +12,15 @@
?>
</div>
<h3>Tipas</h3>
<div style="border: 1px solid #666; margin-right: 20px">
<?php
getSiteTree( 'type' );
?>
</div>
<?php
/*
<h3>Tipas</h3>
<div style="border: 1px solid #666; margin-right: 20px; margin-bottom: 20px;">
<ul>
......@@ -23,6 +32,8 @@
<li><a href="#" style="color: #900">Papildomas darbas</a></li>
</ul>
</div>
*/
?>
<?php
/*
......
<?php
// https://torquemag.io/2017/10/add-breadcrumbs-wordpress-website/
if ( !function_exists('yoast_breadcrumb') || is_front_page() || searchQuery) :
if ( !function_exists('yoast_breadcrumb') || is_front_page() || is_search() ) :
return;
endif;
......
<?php
global $query_string;
if ( cityID && !searchQuery ) :
$page = get_term_meta( cityID, 'page-id', true);
wp_parse_str( $query_string, $searchQuery );
if ( $page ) :
if ( is_search() ) :
if ( $searchQuery['city'] && intval( $searchQuery['city'] ) && !$searchQuery['s'] ) :
$page = get_term_meta( $searchQuery['city'], 'page-id', true);
if ( $page ) :
?>
<link rel="canonical" href="<?php echo get_page_link( $page['ID'] ); ?>" />
<?php
return;
endif;
elseif ( !$searchQuery['city'] && $searchQuery['s'] ) :
$term = get_term_by( 'name', $searchQuery['s'], 'field' );
if ( !$term ) {
$term = get_term_by( 'name', $searchQuery['s'], 'type' );
}
if ( $term ) {
$page = get_term_meta( $term->term_id, 'page-id', true);
if ( $page ) :
?>
<link rel="canonical" href="<?php echo get_page_link( $page['ID'] ); ?>" />
<link rel="canonical" href="<?php echo get_page_link( $page['ID'] ); ?>" />
<?php
return;
endif;
}
endif;
elseif ( !cityID && !searchQuery && get_post_type() == 'page' && get_post_meta( get_the_ID(), 'built_in_taxonomies_city', true ) ):
?>
<meta name="robots" content="noindex" />
<?php
elseif ( get_post_type() == 'page' ):
if ( get_post_meta( get_the_ID(), 'built_in_taxonomies_city', true ) || get_post_meta( get_the_ID(), 'built_in_taxonomies_type', true ) || get_post_meta( get_the_ID(), 'built_in_taxonomies_field', true ) ) :
?>
<link rel="canonical" href="<?php echo get_permalink(); ?>" />
<?php
endif;
endif;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment