🖥️ wip: Homepage search taxonomy configuration
This commit is contained in:
20
templates/filter-homepage-bak.php
Normal file
20
templates/filter-homepage-bak.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php if (!defined('ABSPATH')) { exit; } ?>
|
||||
|
||||
<form class="flex w-full" id="homepage-filter" action="<?php echo site_url('/browse-resources/'); ?>" method="POST">
|
||||
<?php
|
||||
$resource_types = get_terms(['taxonomy' => 'resource_type']);
|
||||
|
||||
if (!empty($resource_types)) :
|
||||
?>
|
||||
<select class="w-fit" name="resource_type">
|
||||
<option value="">All Types</option>
|
||||
<?php foreach ($resource_types as $type) : ?>
|
||||
<option value="<?php echo esc_attr($type->slug); ?>"><?php echo esc_html($type->name); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php endif; ?>
|
||||
|
||||
<input class="full-width" type="text" name="search" placeholder="Search resources...">
|
||||
|
||||
<button class="btn btn-primary" type="submit">Search</button>
|
||||
</form>
|
||||
@@ -1,20 +1,35 @@
|
||||
<?php if (!defined('ABSPATH')) { exit; } ?>
|
||||
<?php
|
||||
if (!defined('ABSPATH')) { exit; } // Prevent direct access
|
||||
|
||||
<form class="flex w-full" id="homepage-filter" action="<?php echo site_url('/browse-resources/'); ?>" method="POST">
|
||||
<?php
|
||||
$resource_types = get_terms(['taxonomy' => 'resource_type']);
|
||||
$homepage_taxonomy = isset($GLOBALS['homepage_taxonomy']) ? $GLOBALS['homepage_taxonomy'] : '';
|
||||
|
||||
if (!empty($resource_types)) :
|
||||
?>
|
||||
<select class="w-fit" name="resource_type">
|
||||
<option value="">All Types</option>
|
||||
<?php foreach ($resource_types as $type) : ?>
|
||||
<option value="<?php echo esc_attr($type->slug); ?>"><?php echo esc_html($type->name); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
if (!empty($homepage_taxonomy)) :
|
||||
$taxonomy_obj = get_taxonomy($homepage_taxonomy);
|
||||
$terms = get_terms(['taxonomy' => $homepage_taxonomy, 'hide_empty' => true]);
|
||||
|
||||
if (!empty($taxonomy_obj) && !empty($terms)) : ?>
|
||||
<form id="homepage-filter">
|
||||
<!-- Search Field -->
|
||||
<div class="search-text">
|
||||
<input class="full-width" type="text" id="search" name="search" placeholder="Search resources..." value="<?php echo isset($search) ? esc_attr($search) : ''; ?>">
|
||||
<button type="reset" id="clear-search">×</button>
|
||||
<button type="submit">Search</button>
|
||||
</div>
|
||||
|
||||
<!-- Single Taxonomy Filter -->
|
||||
<div class="search-tax">
|
||||
<details class="taxonomy-filter" data-taxonomy="<?php echo esc_attr($homepage_taxonomy); ?>">
|
||||
<summary><?php echo esc_html($taxonomy_obj->labels->singular_name); ?></summary>
|
||||
<div class="filter-options">
|
||||
<?php foreach ($terms as $term) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="<?php echo esc_attr($homepage_taxonomy); ?>[]" value="<?php echo esc_attr($term->slug); ?>">
|
||||
<?php echo esc_html($term->name); ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<input class="full-width" type="text" name="search" placeholder="Search resources...">
|
||||
|
||||
<button class="btn btn-primary" type="submit">Search</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user