search results in three columns

This commit is contained in:
jorge 2022-04-11 03:31:19 +02:00
parent 9110bfe34d
commit 003f3443b2
7 changed files with 157 additions and 62 deletions

View File

@ -25,7 +25,7 @@ else:
endif;
?>
<article>
<article>
<main>
<?php
// https://codex.wordpress.org/Conditional_Tags
@ -33,11 +33,11 @@ endif;
//https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130
get_template_part( 'template-parts/section', 'resources', array( 'post_per_page' => '10' ) );
elseif ( is_category( 'news' ) ):
// get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => 'news', 'post_per_page' => '3' ) );
get_template_part( 'template-parts/section', 'categoryposts', array( 'post_per_page' => '3' ) );
$thiscategoryname = esc_html( get_the_category()[0]->name );
get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => $thiscategoryname,'post_per_page' => '3' ) );
elseif ( is_category( '' ) ):
get_template_part( 'template-parts/section', 'categoryposts', array('post_per_page' => '6' ) );
$thiscategoryname = esc_html( get_the_category()[0]->name );
get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => $thiscategoryname,'post_per_page' => '6' ) );
else :
?>
@ -63,17 +63,9 @@ endif;
</nav>
<?php endif; ?>
<?php
endif;//end if is archive_resource
?>
</main>
</article>
<?php get_footer();

File diff suppressed because one or more lines are too long

View File

@ -69,10 +69,10 @@ main {
//
// category view and news
// category view, news, search results
//--------------
.category-posts,.archive-posts {
.category-posts,.archive-posts,.search-results {
@include xy-grid;
header,main,aside {
@include breakpoint(small){
@ -168,8 +168,18 @@ main {
}
}
}
// end category-posts
.search-results {
article {
main {
.search-results-elements {
h1,h2,h3,h4,h5,h6 {
display: block;
}
}
}
}
}
// end category view, news, search results
//
@ -205,7 +215,7 @@ main {
aside {
}
}
// end news & resources category
// end collections category
//
// partners

75
search.php Normal file
View File

@ -0,0 +1,75 @@
<?php
/**
* The search 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.
*
* Learn more: {@link https://codex.wordpress.org/Template_Hierarchy}
*
* @package arcHIVE-theme
* @since arcHIVE-theme 1.0.0
*/
get_header(); ?>
<article>
<main>
<section class="search-results-elements">
<header>
<h4>search results for:</h4>
<h2>
<span class="search-query-terms">
<?php echo get_search_query( ); ?>
</h2>
</header>
<main class="">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<article class="">
<?php if ( has_post_thumbnail() ) :?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
<figure style="background-image: url(<?php echo get_the_post_thumbnail_url();?>);">
</figure>
</a>
<?php else :?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
<figure style="background-image: url(<?php echo catch_post_first_image();?>);">
</figure>
</a>
<?php endif;?>
<h5 class="date">
<?php the_date('d.m.Y');?>
</h5>
<h3 class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</h3>
<section class="excerpt post-excerpt">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
<?php the_excerpt() ?>
</a>
</section>
</article>
<?php endwhile;//end of the loop ?>
</main>
<?php //pagination here ?>
<aside>
<nav>
<!--a href="" class="button hollow">see more news</a-->
</nav>
</aside>
<?php wp_reset_postdata(); ?>
<?php else : //if no post in query ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</main>
</article>
<?php get_footer();

View File

@ -69,10 +69,10 @@ main {
//
// category view and news
// category view, news, search results
//--------------
.category-posts,.archive-posts {
.category-posts,.archive-posts,.search-results {
@include xy-grid;
header,main,aside {
@include breakpoint(small){
@ -168,8 +168,18 @@ main {
}
}
}
// end category-posts
.search-results {
article {
main {
.search-results-elements {
h1,h2,h3,h4,h5,h6 {
display: block;
}
}
}
}
}
// end category view, news, search results
//
@ -205,7 +215,7 @@ main {
aside {
}
}
// end news & resources category
// end collections category
//
// partners

View File

@ -12,14 +12,22 @@
//https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130
// var_dump( $args ); //will display everythin imported from
// get_template_part( 'template-parts/section', 'category', array('category_name' => 'news', 'post_per_page' => '3' ) );
// $thiscategory = $args['category_name'];
$howmanyposts = $args['post_per_page'];
$thiscategory = esc_html( get_the_category()[0]->name );
$thiscategory = $args['category_name'];
?>
<section class="category-posts <?php echo $thiscategory;?> ">
<header>
<h2><?php single_cat_title();?></h2>
<h2>
<?php
if ( is_category() ):
single_cat_title();
else:
echo $thiscategory;
endif;
?>
</h2>
</header>
<main class="">
<?php $the_query = new WP_Query( array( 'category_name' => $thiscategory, 'posts_per_page' => $howmanyposts ) ); ?>