mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-17 15:45:44 +03:00
Pledge List: Display pledges in list with sort and search ability (#33)
* Use the post-type when choosing template partial * Add pledge archive templates * Style pledge list page * Style individual pledge * Use pledge featured image for the logo * Fix aspect ratio of image * Add real contributors to the pledges * Enable sorting and searching of pledges * Add pledge sorting markup * Style the page header * Restrict any pledges with no contributors from being shown on the frontend * Update contributor count key name
This commit is contained in:
parent
f47024efda
commit
553247cbf7
13 changed files with 398 additions and 10 deletions
72
themes/wporg-5ftf/archive-5ftf_pledge.php
Normal file
72
themes/wporg-5ftf/archive-5ftf_pledge.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace WordPressdotorg\Five_for_the_Future\Theme;
|
||||
|
||||
use const WordPressDotOrg\FiveForTheFuture\Pledge\CPT_ID;
|
||||
|
||||
// If we don't have any posts to display for the archive, then send a 404 status. See #meta4151.
|
||||
if ( ! have_posts() ) {
|
||||
status_header( 404 );
|
||||
nocache_headers();
|
||||
}
|
||||
|
||||
get_header(); ?>
|
||||
|
||||
<main id="main" class="site-main" role="main">
|
||||
|
||||
<?php if ( have_posts() ) : ?>
|
||||
|
||||
<header class="page-header">
|
||||
<h1 class="page-title"><?php esc_html_e( 'Pledges', 'wordpressorg' ); ?></h1>
|
||||
<div class="page-header-callout">
|
||||
<a class="button" href="/for-organizations/" >
|
||||
<?php esc_html_e( 'Pledge your company', 'wordpressorg' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="page-header-controls">
|
||||
<form method="get" action="<?php echo esc_url( get_post_type_archive_link( CPT_ID ) ); ?>">
|
||||
<label for="pledge-sort"><?php esc_html_e( 'Sort pledges by', 'wordpressorg' ); ?></label>
|
||||
<select class="custom-select" id="pledge-sort" name="order">
|
||||
<option value="" <?php selected( $_GET['order'], '' ); ?>>
|
||||
<?php esc_html_e( 'All Pledges', 'wordpressorg' ); ?>
|
||||
</option>
|
||||
<option value="alphabetical" <?php selected( $_GET['order'], 'alphabetical' ); ?>>
|
||||
<?php esc_html_e( 'Alphabetical', 'wordpressorg' ); ?>
|
||||
</option>
|
||||
<option value="contributors" <?php selected( $_GET['order'], 'contributors' ); ?>>
|
||||
<?php esc_html_e( 'Total Contributors', 'wordpressorg' ); ?>
|
||||
</option>
|
||||
</select>
|
||||
<span class="screen-reader-text">
|
||||
<input type="submit" />
|
||||
</span>
|
||||
</form>
|
||||
|
||||
<?php get_search_form(); ?>
|
||||
</div>
|
||||
</header><!-- .page-header -->
|
||||
|
||||
<?php
|
||||
|
||||
while ( have_posts() ) :
|
||||
the_post();
|
||||
|
||||
get_template_part( 'template-parts/content', get_post_type() );
|
||||
|
||||
endwhile;
|
||||
|
||||
the_posts_pagination();
|
||||
|
||||
?>
|
||||
|
||||
<?php else :
|
||||
|
||||
get_template_part( 'template-parts/content', 'none' );
|
||||
|
||||
endif; ?>
|
||||
|
||||
</main><!-- #main -->
|
||||
|
||||
<?php
|
||||
get_footer();
|
Loading…
Add table
Add a link
Reference in a new issue