add resources back link to category

This commit is contained in:
jorge 2022-04-24 23:11:44 +02:00
parent 4a52a13fdb
commit 97a77057ac
10 changed files with 311 additions and 14 deletions

View File

@ -31,13 +31,14 @@ endif;
// 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' ) );
get_template_part( 'template-parts/archive', 'resources');
elseif ( is_category( 'news' ) ): elseif ( is_category( 'news' ) ):
$thiscategoryname = esc_html( get_the_category()[0]->name ); $thiscategoryname = esc_html( get_the_category()[0]->name );
get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => $thiscategoryname,'post_per_page' => '3' ) ); get_template_part( 'template-parts/archive', 'categoryposts', array( 'category_name' => $thiscategoryname,'post_per_page' => '6' ) );
elseif ( is_category( '' ) ): elseif ( is_category( '' ) ):
$thiscategoryname = esc_html( get_the_category()[0]->name ); $thiscategoryname = esc_html( get_the_category()[0]->name );
get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => $thiscategoryname,'post_per_page' => '6' ) ); get_template_part( 'template-parts/archive', 'categoryposts', array( 'category_name' => $thiscategoryname,'post_per_page' => '6' ) );
else : else :
?> ?>

File diff suppressed because one or more lines are too long

View File

@ -72,9 +72,18 @@ main {
} }
} }
} }
aside {
@include xy-grid;
nav {
@include xy-cell(12);
display:flex;
align-content: center;
justify-content: center;
padding-bottom: $global-padding * 2;
}
}
} }
// //
// category view, news, search results // category view, news, search results
//-------------- //--------------

View File

@ -23,7 +23,7 @@ get_header(); ?>
<main> <main>
<?php <?php
//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', 'categoryposts', array('category_name' => 'featured-artworks', 'post_per_page' => '6' ) ); get_template_part( 'template-parts/section', 'categoryposts', array('category_name' => 'featured-artworks', 'post_per_page' => '3' ) );
?> ?>
</main> </main>
</article> </article>

View File

@ -0,0 +1,71 @@
<?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.
*
* Learn more: {@link https://codex.wordpress.org/Template_Hierarchy}
*
* @package arcHIVE-theme
* @since arcHIVE-theme 1.0.0
*/
get_header(); ?>
<article>
<main>
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php //get_template_part( 'template-parts/content', get_post_format() ); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header>
<?php
if ( is_single() ) {
the_title( '<h1 class="entry-title">', '</h1>' );
} else {
the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
}
?>
<?php //foundationpress_entry_meta(); ?>
</header>
<div class="entry-content">
<?php the_content(); ?>
<?php edit_post_link( __( '(Edit)', 'foundationpress' ), '<span class="edit-link">', '</span>' ); ?>
</div>
</article>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; // End have_posts() check. ?>
<aside>
<nav>
<a class="button hollow" href="<?php echo get_post_type_archive_link( 'archive_resource' ) ?>">back to resources</a>
</nav>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php
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; ?>
</aside>
</main>
<?php //get_template_part( 'template-parts/announcement' ); ?>
<?php get_footer();

View File

@ -72,9 +72,18 @@ main {
} }
} }
} }
aside {
@include xy-grid;
nav {
@include xy-cell(12);
display:flex;
align-content: center;
justify-content: center;
padding-bottom: $global-padding * 2;
}
}
} }
// //
// category view, news, search results // category view, news, search results
//-------------- //--------------

View File

@ -0,0 +1,90 @@
<?php
/**
* The section containing preview of news category posts
*
* @package arcHIVE-theme
* @since arcHIVE-theme 1.0.0
*/
?>
<?php
//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' ) );
$howmanyposts = $args['post_per_page'];
$thiscategory = $args['category_name'];
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
?>
<section class="category-posts <?php echo $thiscategory;?> ">
<header>
<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 , 'paged' => $paged ) ); ?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->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
if ( is_category( 'news' ) ):
the_date('d.m.Y');
else:
the_date('Y');
endif;
?>
</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 wp_reset_postdata(); ?>
<?php else : //if no post in query ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
</main>
<?php endif; ?>
<aside>
<?php //get_template_part( 'template-parts/navigation', 'prevnext' ); ?>
<nav>
<div class="post-previous"><?php previous_posts_link( __( 'Newer posts &rarr;', 'foundationpress' ) ); ?></div>
<div class="post-next"><?php next_posts_link( __( '&larr; Older posts', 'foundationpress' ) ); ?></div>
<?php
// button load more simple
// echo '<a class="button hollow" href="' . esc_url( get_category_link( get_cat_ID($thiscategory) ) ) . '">';
// echo 'load more ' ;
// echo $thiscategory;
// echo '</a>';
?>
</nav>
</aside>
</section>

View File

@ -0,0 +1,74 @@
<?php
/**
* The archive containing preview of resources
*
* @package arcHIVE-theme
* @since arcHIVE-theme 1.0.0
*/
?>
<?php
//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' ) );
// $thiscustomposttype = get_post_type( get_the_ID() );
// $howmanyposts = $args['post_per_page'];
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
?>
<section class="archive-posts resources">
<header>
<h2>
<?php
if ( is_post_type_archive() ):
post_type_archive_title();
endif;
?>
</h2>
</header>
<main class="">
<?php $the_query = new WP_Query( array( 'post_type' => get_post_type( get_the_ID() ), 'posts_per_page' => '10' , 'paged' => $paged ) ); ?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->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('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 ?>
<?php //pagination here ?>
<?php wp_reset_postdata(); ?>
<?php else : //if no post in query ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</main>
<aside>
<nav>
<div class="post-previous"><?php previous_posts_link( __( 'Newer posts &rarr;', 'foundationpress' ) ); ?></div>
<div class="post-next"><?php next_posts_link( __( '&larr; Older posts', 'foundationpress' ) ); ?></div>
</nav>
</aside>
</section>

View File

@ -0,0 +1,35 @@
<?php
/**
* Display navigation to next previous pages when applicable
*
* @package arcHIVE-theme
* @since arcHIVE-theme 1.0.0
*/
?>
<?php
?>
<nav>
<?php //pagination here ?>
<?php if ( is_category() ): ?>
<?php
// button load more simple
//echo '<a class="button hollow" href="' . echo esc_url( get_category_link( ) ) . '">';
echo '<a class="button hollow" href="">';
echo 'load more ' ;
echo single_cat_title();
echo '</a>';
?>
<?php else: ?>
<?php
// button load more simple
echo '<a class="button hollow" href="' . esc_url( get_category_link( get_cat_ID($thiscategory) ) ) . '">';
echo 'load more ' ;
echo $thiscategory;
echo '</a>';
?>
<?php endif; ?>
<?php //END pagination ?>
</nav>

View File

@ -66,15 +66,23 @@
</section> </section>
</article> </article>
<?php endwhile;//end of the loop ?> <?php endwhile;//end of the loop ?>
<?php //pagination here ?> </main>
<?php wp_reset_postdata(); ?> <?php wp_reset_postdata(); ?>
<?php else : //if no post in query ?> <?php else : //if no post in query ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</main> </main>
<?php endif; ?>
<aside> <aside>
<?php //get_template_part( 'template-parts/navigation', 'prevnext' ); ?>
<nav> <nav>
<!--a href="" class="button hollow">see more news</a--> <?php
// button load more simple
echo '<a class="button hollow" href="' . esc_url( get_category_link( get_cat_ID($thiscategory) ) ) . '">';
echo 'load more ' ;
echo $thiscategory;
echo '</a>';
?>
</nav> </nav>
</aside> </aside>
</section> </section>