Rebalance: Add page password protection for portfolio page (#6008)

* Rebalance: Add page password protection for portfolio items on the portfolio page

* Clarify the password protection condition with the comment
This commit is contained in:
Wojtek Naruniec 2022-05-24 18:28:50 +02:00 committed by GitHub
parent ab437b49ca
commit a2da1cdb35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,12 @@ get_header(); ?>
<div id="primary" class="content-area">
<?php
// if password is required for this page, let's use the_content() to display the password form.
if ( post_password_required() ) :
the_content();
else :
/*
* Include the Featured Project loop.
* - if featured posts exist, collect their IDs and exclude them from the main loop
@ -24,11 +30,13 @@ get_header(); ?>
get_template_part( 'template-parts/section', 'featured' );
} else {
$featured_ids = null;
} ?>
}
?>
<main id="main" class="site-main" role="main">
<?php // Set Up New Query
<?php
// Set Up New Query
if ( get_query_var( 'paged' ) ) :
$paged = get_query_var( 'paged' );
elseif ( get_query_var( 'page' ) ) :
@ -42,19 +50,25 @@ get_header(); ?>
$temp = null;
$project_query = $temp;
$project_query = new WP_Query();
$project_query->query( array(
$project_query->query(
array(
'post_type' => 'jetpack-portfolio',
'paged' => $paged,
'posts_per_page' => $posts_per_page,
'post__not_in' => $featured_ids
) ); ?>
'post__not_in' => $featured_ids,
)
);
?>
<?php if ( $project_query->have_posts() ) : ?>
<div id="infinite-wrap">
<?php /* Start the Loop */ ?>
<?php while ( $project_query->have_posts() ) : $project_query->the_post(); ?>
<?php
while ( $project_query->have_posts() ) :
$project_query->the_post();
?>
<?php
/*
@ -75,15 +89,21 @@ get_header(); ?>
<?php endif; ?>
<?php // Empty queries
<?php
// Empty queries
$project_query = $temp;
$temp = null; ?>
$temp = null;
?>
<?php // Reset posts so our normal loop isn't affected
wp_reset_postdata(); ?>
<?php
// Reset posts so our normal loop isn't affected
wp_reset_postdata();
?>
</main><!-- #main -->
<?php endif; // end post_password_required() ?>
</div><!-- #primary -->
<?php get_sidebar(); ?>