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,55 +25,47 @@ else:
endif; endif;
?> ?>
<article> <article>
<main> <main>
<?php <?php
// https://codex.wordpress.org/Conditional_Tags // https://codex.wordpress.org/Conditional_Tags
if ( is_post_type_archive ( 'archive_resource' ) ) : if ( is_post_type_archive ( 'archive_resource' ) ) :
//https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130 //https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130
get_template_part( 'template-parts/section', 'resources', array( 'post_per_page' => '10' ) ); get_template_part( 'template-parts/section', 'resources', array( 'post_per_page' => '10' ) );
elseif ( is_category( 'news' ) ): elseif ( is_category( 'news' ) ):
// get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => 'news', 'post_per_page' => '3' ) ); $thiscategoryname = esc_html( get_the_category()[0]->name );
get_template_part( 'template-parts/section', 'categoryposts', array( 'post_per_page' => '3' ) ); get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => $thiscategoryname,'post_per_page' => '3' ) );
elseif ( is_category( '' ) ): 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 :
?>
<?php if ( have_posts() ) :
// Start the Loop
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
endwhile;
else : else :
get_template_part( 'template-parts/content', 'none' );
endif; // End have_posts() check.
?> ?>
<?php if ( have_posts() ) :
// Start the Loop
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
endwhile;
else :
get_template_part( 'template-parts/content', 'none' );
endif; // End have_posts() check.
?>
<?php
// Display navigation to next/previous pages when applicable
if ( function_exists( 'foundationpress_pagination' ) ) :
foundationpress_pagination();
elseif ( is_paged() ) :
?>
<nav id="post-nav">
<div class="post-previous"><?php next_posts_link( __( '&larr; Older posts', 'foundationpress' ) ); ?></div>
<div class="post-next"><?php previous_posts_link( __( 'Newer posts &rarr;', 'foundationpress' ) ); ?></div>
</nav>
<?php endif; ?>
<?php <?php
// Display navigation to next/previous pages when applicable
endif;//end if is archive_resource if ( function_exists( 'foundationpress_pagination' ) ) :
foundationpress_pagination();
elseif ( is_paged() ) :
?> ?>
<nav id="post-nav">
<div class="post-previous"><?php next_posts_link( __( '&larr; Older posts', 'foundationpress' ) ); ?></div>
<div class="post-next"><?php previous_posts_link( __( 'Newer posts &rarr;', 'foundationpress' ) ); ?></div>
</nav>
<?php endif; ?>
<?php
</main> endif;//end if is archive_resource
</article> ?>
</main>
</article>
<?php get_footer(); <?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; @include xy-grid;
header,main,aside { header,main,aside {
@include breakpoint(small){ @include breakpoint(small){
@ -168,8 +168,18 @@ main {
} }
} }
} }
.search-results {
// end category-posts 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 { aside {
} }
} }
// end news & resources category // end collections category
// //
// partners // 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; @include xy-grid;
header,main,aside { header,main,aside {
@include breakpoint(small){ @include breakpoint(small){
@ -168,8 +168,18 @@ main {
} }
} }
} }
.search-results {
// end category-posts 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 { aside {
} }
} }
// end news & resources category // end collections category
// //
// partners // partners

View File

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