Commit d8cb3c33 authored by Simonas's avatar Simonas

Search page update

parent 4d401190
......@@ -28,6 +28,16 @@ get_header(); ?>
<?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();
......
</main><!-- .l-main -->
<?php
if ( !searchQuery && !cityID && get_post_type() == 'job' ):
if ( !is_search() && get_post_type() == 'job' ):
?>
<aside class="l-aside">
<?php
......
......@@ -284,11 +284,31 @@ add_action('init', 'df_disable_comments_admin_bar');
$l = get_nav_menu_locations();
$m = $l ? wp_get_nav_menu_object( $l[ 'main-menu' ] ) : null;
$items = $m ? wp_get_nav_menu_items( $m->term_id, array( 'order' => 'DESC' ) ) : array();
$searchPageURL = $items[0] ? $items[0]->url : '/';
// $l = get_nav_menu_locations();
// $m = $l ? wp_get_nav_menu_object( $l[ 'main-menu' ] ) : null;
// $items = $m ? wp_get_nav_menu_items( $m->term_id, array( 'order' => 'DESC' ) ) : array();
// $searchPageURL = $items[0] ? $items[0]->url : '/';
// global $searchPageURL;
// $searchPage = new WP_Query( array(
// 'numberposts' => 1,
// 'post_type' => 'page',
// 'meta_key' => 'search-page',
// 'meta_value' => 'true'
// ) );
// if ( $searchPage->have_posts() ) :
// while( $searchPage->have_posts() ) :
// $searchPage->the_post();
// $searchPageURL = get_the_permalink();
// endwhile;
// else:
// $searchPageURL = '/';
// endif;
// delog( $searchPageURL );
// require_once 'includes/disable_discussion';
......
......@@ -58,7 +58,6 @@ $section = get_post_meta( $post->ID, 'section', true );
?>
<body>
<svg xmlns="http://www.w3.org/2000/svg" class="u-hidden">
<symbol id="biuro-logo" viewBox="0 0 108 63" aria-labelledby="svg-title svg-desc">
<title id="svg-title">Biuro</title>
......@@ -94,9 +93,24 @@ $section = get_post_meta( $post->ID, 'section', true );
?>
</div>
<div class="l-inner">
<?php
/*
delog( get_search_query(), 'Search Query');
delog( get_post_type(), 'Post type');
delog( get_page_template_slug(), 'slug');
delog( is_front_page(), 'is_front_page');
delog( is_search(), 'is_search');
*/
?>
</div>
<div id="main" class="l-content">
<?php
if ( !is_front_page() && get_post_type() == 'page' && get_page_template_slug() == 'page-jobs.php' || is_search() ):
// 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
......
......@@ -17,6 +17,9 @@
get_header(); ?>
<h1>index.php</h1>
<?php
if ( is_search() ):
?>
......
<?php
/**
*
get_header(); ?>
<?php
global $query_string;
$query_args = explode("&", $query_string);
debug( $query_args );
$search_query = array();
foreach($query_args as $key => $string) {
$query_split = explode("=", $string);
$search_query[$query_split[0]] = urldecode($query_split[1]);
} // foreach
debug( $search_query );
$the_query = new WP_Query($search_query);
// $query = new WP_Query( array( 'author_name' => 'carlo' ) );
// $args = array(
// 'post_type' => 'accommodation',
// 'meta_query' => array(
// array( 'key' => 'city', 'value' => 'Paris', 'compare' => 'LIKE' ),
// array( 'key' => 'type', 'value' => 'room', 'compare' => 'LIKE' ),
// 'relation' => 'AND'
// )
// );
// $the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
?>
<!-- the loop -->
<h1>Lorem ipsum - Search</h1>
<ul>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
<!-- end of the loop -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<h1>Lorem ipsum - Search</h1>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
<?php get_footer();
*/
?>
<?php
/**
* Template Name: Search & Jobs page
*
* 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
if ( !is_search() ):
while ( have_posts() ) :
the_post();
the_content();
endwhile;
endif;
?>
<?php
global $query_string;
$ID = get_the_ID();
$keys = get_post_custom_keys();
$where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '"';
if ( is_search() ):
wp_parse_str( $query_string, $searchQuery );
if ( $searchQuery ) :
if ( $searchQuery['city'] ) :
$where = $where . ' AND city.term_id = ' . $searchQuery['city'];
endif;
if ( $searchQuery['s'] ) :
$where = $where . ' AND (t.post_title LIKE "%' . $searchQuery['s'] . '%" OR t.post_content LIKE "%' . $searchQuery['s'] . '%")';
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 . '%")';
elseif ($keys):
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;
endif;
$term = $res[0];
if ( !$term ) :
continue;
endif;
$where = $where . ' AND ' . $taxonomy . '.slug = "' . $term . '"';
endforeach;
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 get_footer();
......@@ -8,9 +8,14 @@
* @version 1.0
*/
// global $searchPageURL;
?>
<form class="c-search" action="<?php echo pll_home_url(); ?>" method="get">
<?php /*
<form class="c-search" action="<?php echo $searchPageURL; ?>" method="get">
*/ ?>
<form class="c-search" action="<?php echo home_url(); ?>" method="get">
<?php
......
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