Skip to content

Instantly share code, notes, and snippets.

@MjHead
Created October 8, 2018 08:16
Show Gist options
  • Save MjHead/a68c030b1210bb72325860d30e63a600 to your computer and use it in GitHub Desktop.
Save MjHead/a68c030b1210bb72325860d30e63a600 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'jet-engine/listings/macros-list', 'jet_register_custom_macros' );
/**
* Add new macros to default macros list
*
* %jet_current_category% - macros name
*
*/
function jet_register_custom_macros( $macros_list ) {
$macros_list['jet_current_category'] = 'jet_current_category';
return $macros_list;
}
/**
* Macros callback function
*/
function jet_current_category() {
$terms = wp_get_post_terms( get_the_ID(), 'taxonomy_name' );
if ( empty( $terms ) || is_wp_error( $terms ) ) {
return null;
}
return $terms[0]->slug;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment