Plugin Author
Paolo
(@paoltaia)
Hi, not using the GD Categories block, but there is a Gutenberg block that can help you with that.
It is called: Terms List
However, it will not use the default pretty permalink.
Instead of sending user to a link like this: https://abbeymeccadev.com/nyspia/places/category/chiropractor/
It will send them to a link like this:
https://abbeymeccadev.com/nyspia/?gd_placecategory=chiropractor
It’s one or the other…
Hey,
Paolo’s solution works, but yeah, it gives you those ugly query string URLs instead of clean permalinks. If you want to keep the pretty URLs without the redirect overhead, just drop in a quick custom shortcode, example:
function gd_category_dropdown_pretty() {
$terms = get_terms([
'taxonomy' => 'gd_placecategory',
'hide_empty' => true,
]);
if (empty($terms) || is_wp_error($terms)) {
return '';
}
ob_start();
?>
<select onchange="if(this.value) window.location.href=this.value;">
<option value=""><?php _e('Select Category', 'geodirectory'); ?></option>
<?php foreach ($terms as $term) :
$link = get_term_link($term);
if (is_wp_error($link)) continue;
?>
<option value="<?php echo esc_url($link); ?>">
<?php echo esc_html($term->name); ?>
</option>
<?php endforeach; ?>
</select>
<?php
return ob_get_clean();
}
add_shortcode('gd_cat_dropdown_pretty', 'gd_category_dropdown_pretty');
Add that to your theme’s functions.php or a code snippets plugin. Then just use [gd_cat_dropdown_pretty] anywhere.