Created
October 8, 2018 08:16
-
-
Save MjHead/a68c030b1210bb72325860d30e63a600 to your computer and use it in GitHub Desktop.
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
<?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