Show only taxonomy types associated with a custom post type in WordPress PHP
Show only taxonomy types associated with a custom post type in WordPress PHP
I am trying to display only the taxonomy types selected on a custom post type "newsroom". The code below shows all taxonomy types for every type of post. Is there a way to show only the types tagged on a post under the custom post type "newsroom"?
<form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
<input type="hidden" name="action" value="resource_filter">
<?php
if( $terms = get_terms( array( 'taxonomy' => 'types', 'orderby' => 'name' ) ) ) { // types
?> <div class="types-filter"><h3>Types</h3> <?php
foreach ( $terms as $term ){ ?>
<label class="MuiFormControlLabel-root">
<span class="MuiButtonBase-root MuiIconButton-root jss317 MuiCheckbox-root MuiCheckbox-colorSecondary MuiIconButton-colorSecondary" aria-disabled="false">
<span class="MuiIconButton-label">
<input type="checkbox" name="types_filter[]" id="checkbox_types_filter_<?php echo $term->term_id; ?>" class="resource-filter-checkbox" value="<?php echo $term->term_id; ?>" data-indeterminate="false" data_term_name="<?php echo $term->name; ?>">
</span>
</span>
<span class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1">
<p class="MuiTypography-root MuiTypography-body2"><?php echo $term->name; ?></p>
</span>
</label>
<?php
}
?>
</div>
<?php
} ?>
</form>
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand