added support for custom Resources and its widget

This commit is contained in:
jorge 2022-03-30 21:00:42 +02:00
parent b6c9e94b92
commit d009ca412d
4 changed files with 160 additions and 35 deletions

View File

@ -17,38 +17,64 @@
get_header(); ?>
<div class="main-container">
<div class="main-grid">
<main class="main-content">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'template-parts/content', get_post_format() ); ?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; // End have_posts() check. ?>
<?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; ?>
</main>
<?php //get_sidebar(); ?>
</div>
</div>
<?php
if ( is_post_type_archive ( 'archive_resource' ) ) :
get_template_part( 'template-parts/announcement', 'resources' );
else:
get_template_part( 'template-parts/announcement', '' );
endif;
?>
<article>
<main>
<?php
// https://codex.wordpress.org/Conditional_Tags
if ( is_post_type_archive ( 'archive_resource' ) ) :
//https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130
get_template_part( 'template-parts/section', 'resources', array( 'custom_post_type' => 'archive_resource', 'post_per_page' => '10' ) );
elseif ( is_category( 'resources' ) ):
get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => 'resources', 'post_per_page' => '10' ) );
elseif ( is_category( '' ) ):
get_template_part( 'template-parts/section', 'categoryposts', array('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 :
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
endif;//end if is archive_resource
?>
</main>
</article>
<?php get_footer();

View File

@ -12,7 +12,7 @@ if ( ! function_exists( 'foundationpress_sidebar_widgets' ) ) :
array(
'id' => 'home-announcement-widgets',
'name' => __( 'Home Announcement widgets', 'foundationpress' ),
'description' => __( 'Drag widgets to this Home page container that will show at the top.', 'foundationpress' ),
'description' => __( 'Drag widgets to this Home page container that will show at the top of the home page.', 'foundationpress' ),
'before_sidebar'=> '<main class="slides">',
'after_sidebar' => '</main>',
'before_widget' => '<section id="%1$s" class="widget slide home-announcement %2$s">',
@ -25,7 +25,7 @@ if ( ! function_exists( 'foundationpress_sidebar_widgets' ) ) :
array(
'id' => 'home-announcement-middle-widgets',
'name' => __( 'Home Announcement Middle widgets', 'foundationpress' ),
'description' => __( 'Drag widgets to this Home page container that will show in the middle.', 'foundationpress' ),
'description' => __( 'Drag widgets to this Home page container that will show in the middle of the home page.', 'foundationpress' ),
'before_sidebar'=> '<main class="slides">',
'after_sidebar' => '</main>',
'before_widget' => '<section id="%1$s" class="widget slide home-middle-announcement %2$s">',
@ -38,7 +38,7 @@ if ( ! function_exists( 'foundationpress_sidebar_widgets' ) ) :
array(
'id' => 'home-announcement-bottom-widgets',
'name' => __( 'Home Announcement Bottom widgets', 'foundationpress' ),
'description' => __( 'Drag widgets to this Home page container that will show at the bottom.', 'foundationpress' ),
'description' => __( 'Drag widgets to this Home page container that will show at the bottom of the home page.', 'foundationpress' ),
'before_sidebar'=> '<main class="slides">',
'after_sidebar' => '</main>',
'before_widget' => '<section id="%1$s" class="widget slide home-bottom-announcement %2$s">',
@ -58,6 +58,17 @@ if ( ! function_exists( 'foundationpress_sidebar_widgets' ) ) :
'after_title' => '</h6>',
)
);
register_sidebar(
array(
'id' => 'announcement-resources-widgets',
'name' => __( 'Announcement Resources widgets', 'foundationpress' ),
'description' => __( 'Drag widgets to this announcement container to be displayed in Resources.', 'foundationpress' ),
'before_widget' => '<section id="%1$s" class="widget slide %2$s">',
'after_widget' => '</section>',
'before_title' => '<h6>',
'after_title' => '</h6>',
)
);
register_sidebar(
array(

View File

@ -0,0 +1,16 @@
<?php
/**
* The breaking div containing the main widget area
*
* @package arcHIVE-theme
* @since arcHIVE-theme 1.0.0
*/
?>
<section class="hero hero-announcement resources">
<?php dynamic_sidebar( 'announcement-resources-widgets' ); ?>
<aside>
<?php //insert menu here; ?>
<?php //foundationpress_announcement_bar(); ?>
</aside>
</section>

View File

@ -0,0 +1,72 @@
<?php
/**
* The section 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 = $args['custom_post_type'];
$howmanyposts = $args['post_per_page'];
?>
<section class="archive-resources">
<header>
<h2>
<?php
if ( is_post_type_archive($thiscustomposttype) ):
//post_type_archive_title();
else:
echo $thiscustomposttype;
endif;?>
</h2>
</header>
<main class="">
<?php $the_query = new WP_Query( array( 'post_type' => $thiscustomposttype, 'posts_per_page' => $howmanyposts ) ); ?>
<?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('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 ?>
<?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>
<!--a href="" class="button hollow">see more news</a-->
</nav>
</aside>
</section>