Last active
October 28, 2022 17:36
-
-
Save cparkinson/68909a5f877d1fe2870c1b35e030a609 to your computer and use it in GitHub Desktop.
uag post grid show all categories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* UAG Post Grid block displays one category for each post | |
* filter to display all categories, | |
* original display remains in block - has to be hidden with CSS | |
*/ | |
function ca_response_single_post_meta_before_meta_grid( $post_id, $attributes ) { | |
//copied from astra/inc/blog/blog-config.php : astra_get_post_meta | |
global $post; | |
//because this overrides the "show category" control in the Post Grid block, | |
//we want to disable it for the homepage, i.e. the Featured section | |
if ( is_front_page() ){ | |
return; | |
} | |
$category = astra_post_categories(); | |
$cat_output_str = ''; | |
$loop_count = 1; | |
$byline_str = ''; | |
if ( '' != $category ) { | |
$cat_output_str .= ( 1 != $loop_count && '' != $cat_output_str ) ? ' ' . $separator . ' ' : ''; | |
$cat_output_str .= $category; | |
} | |
?> | |
<?php | |
$locations = get_the_terms( $post->ID, 'location' ); | |
if ( ! empty( $locations ) ) { | |
$locations_postmeta = ca_response_get_location_metadata($locations); | |
//check to see if this is blank | |
if (! empty( $locations_postmeta )){ | |
?> | |
<div class="entry-meta grid-locations"> | |
<div class="locations-meta">Locations: <?php echo $locations_postmeta; ?></div> | |
</div> | |
<?php | |
} | |
} | |
} | |
add_action( 'uagb_single_post_before_meta_grid', 'ca_response_single_post_meta_before_meta_grid', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment