added support for custom Resources and its widget
This commit is contained in:
parent
b6c9e94b92
commit
d009ca412d
78
archive.php
78
archive.php
|
@ -17,38 +17,64 @@
|
||||||
|
|
||||||
get_header(); ?>
|
get_header(); ?>
|
||||||
|
|
||||||
<div class="main-container">
|
<?php
|
||||||
<div class="main-grid">
|
if ( is_post_type_archive ( 'archive_resource' ) ) :
|
||||||
<main class="main-content">
|
get_template_part( 'template-parts/announcement', 'resources' );
|
||||||
<?php if ( have_posts() ) : ?>
|
else:
|
||||||
|
get_template_part( 'template-parts/announcement', '' );
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
|
|
||||||
<?php /* Start the Loop */ ?>
|
<article>
|
||||||
<?php while ( have_posts() ) : the_post(); ?>
|
<main>
|
||||||
<?php get_template_part( 'template-parts/content', get_post_format() ); ?>
|
<?php
|
||||||
<?php endwhile; ?>
|
// https://codex.wordpress.org/Conditional_Tags
|
||||||
|
if ( is_post_type_archive ( 'archive_resource' ) ) :
|
||||||
|
|
||||||
<?php else : ?>
|
//https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130
|
||||||
<?php get_template_part( 'template-parts/content', 'none' ); ?>
|
get_template_part( 'template-parts/section', 'resources', array( 'custom_post_type' => 'archive_resource', 'post_per_page' => '10' ) );
|
||||||
|
|
||||||
<?php endif; // End have_posts() check. ?>
|
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' ) );
|
||||||
|
|
||||||
<?php /* Display navigation to next/previous pages when applicable */ ?>
|
else :
|
||||||
<?php
|
?>
|
||||||
if ( function_exists( 'foundationpress_pagination' ) ) :
|
|
||||||
foundationpress_pagination();
|
<?php if ( have_posts() ) :
|
||||||
elseif ( is_paged() ) :
|
// Start the Loop
|
||||||
?>
|
while ( have_posts() ) : the_post();
|
||||||
<nav id="post-nav">
|
get_template_part( 'template-parts/content', get_post_format() );
|
||||||
<div class="post-previous"><?php next_posts_link( __( '← Older posts', 'foundationpress' ) ); ?></div>
|
endwhile;
|
||||||
<div class="post-next"><?php previous_posts_link( __( 'Newer posts →', 'foundationpress' ) ); ?></div>
|
else :
|
||||||
</nav>
|
get_template_part( 'template-parts/content', 'none' );
|
||||||
<?php endif; ?>
|
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( __( '← Older posts', 'foundationpress' ) ); ?></div>
|
||||||
|
<div class="post-next"><?php previous_posts_link( __( 'Newer posts →', 'foundationpress' ) ); ?></div>
|
||||||
|
</nav>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
endif;//end if is archive_resource
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
</main>
|
||||||
|
</article>
|
||||||
|
|
||||||
</main>
|
|
||||||
<?php //get_sidebar(); ?>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<?php get_footer();
|
<?php get_footer();
|
||||||
|
|
|
@ -12,7 +12,7 @@ if ( ! function_exists( 'foundationpress_sidebar_widgets' ) ) :
|
||||||
array(
|
array(
|
||||||
'id' => 'home-announcement-widgets',
|
'id' => 'home-announcement-widgets',
|
||||||
'name' => __( 'Home Announcement widgets', 'foundationpress' ),
|
'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">',
|
'before_sidebar'=> '<main class="slides">',
|
||||||
'after_sidebar' => '</main>',
|
'after_sidebar' => '</main>',
|
||||||
'before_widget' => '<section id="%1$s" class="widget slide home-announcement %2$s">',
|
'before_widget' => '<section id="%1$s" class="widget slide home-announcement %2$s">',
|
||||||
|
@ -25,7 +25,7 @@ if ( ! function_exists( 'foundationpress_sidebar_widgets' ) ) :
|
||||||
array(
|
array(
|
||||||
'id' => 'home-announcement-middle-widgets',
|
'id' => 'home-announcement-middle-widgets',
|
||||||
'name' => __( 'Home Announcement Middle widgets', 'foundationpress' ),
|
'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">',
|
'before_sidebar'=> '<main class="slides">',
|
||||||
'after_sidebar' => '</main>',
|
'after_sidebar' => '</main>',
|
||||||
'before_widget' => '<section id="%1$s" class="widget slide home-middle-announcement %2$s">',
|
'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(
|
array(
|
||||||
'id' => 'home-announcement-bottom-widgets',
|
'id' => 'home-announcement-bottom-widgets',
|
||||||
'name' => __( 'Home Announcement Bottom widgets', 'foundationpress' ),
|
'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">',
|
'before_sidebar'=> '<main class="slides">',
|
||||||
'after_sidebar' => '</main>',
|
'after_sidebar' => '</main>',
|
||||||
'before_widget' => '<section id="%1$s" class="widget slide home-bottom-announcement %2$s">',
|
'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>',
|
'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(
|
register_sidebar(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -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>
|
|
@ -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>
|
Loading…
Reference in New Issue