diff --git a/src/php/archive.php b/src/php/archive.php index 9bfe467..5e60572 100644 --- a/src/php/archive.php +++ b/src/php/archive.php @@ -3,11 +3,6 @@ * The template for displaying archive pages */ -$page_num = get_query_var( 'paged' ); -$page_num = empty( $page_num ) ? 1 : $page_num; -$posts_per_page = 12; -$count = $GLOBALS['wp_query']->post_count; - $templates = array( 'archive.twig', 'index.twig' ); $context = Timber\Timber::context(); diff --git a/src/php/functions.php b/src/php/functions.php index 9d4d940..9607697 100644 --- a/src/php/functions.php +++ b/src/php/functions.php @@ -85,9 +85,9 @@ function add_to_context( $context ) { /** * Render page content with password protection. * - * @param object $post - The current post. + * @param object $post - The current post. * @param string|array $templates - The template(s) to render. - * @param object $context - The Timber context used to render. + * @param object $context - The Timber context used to render. */ function render_with_password_protection( $post, $templates, $context ) { if ( post_password_required( $post->ID ) ) { @@ -96,3 +96,18 @@ function render_with_password_protection( $post, $templates, $context ) { Timber::render( $templates, $context ); } } + +/** + * Filter password protected posts out of listing page queries. + * + * @param object $query - The incoming query. + * @return object + */ +function filter_password_protected_posts( $query ) { + if ( ! $query->is_admin && ! $query->is_single ) { + $query->set( 'has_password', false ); + } + + return $query; +} +add_filter( 'pre_get_posts', 'filter_password_protected_posts' ); diff --git a/src/php/search.php b/src/php/search.php index 283307b..f2ad012 100644 --- a/src/php/search.php +++ b/src/php/search.php @@ -7,7 +7,9 @@ */ $context = Timber\Timber::context(); -$context['title'] = 'Search results for ' . get_search_query(); + +$search_term = get_search_query(); +$context['title'] = 'Search results for ' . $search_term; $context['posts'] = new Timber\PostQuery(); Timber\Timber::render( 'search.twig', $context ); diff --git a/wp-configs/.htaccess b/wp-configs/.htaccess index a182ccf..6f770d5 100644 --- a/wp-configs/.htaccess +++ b/wp-configs/.htaccess @@ -2,14 +2,6 @@ # The directives (lines) between "BEGIN WordPress" and "END WordPress" are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. - -RewriteEngine On -RewriteBase / -RewriteRule ^index\.php$ - [L] -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule . /index.php [L] - # END WordPress