Skip to content

Instantly share code, notes, and snippets.

@Crocoblock
Last active November 14, 2025 13:11
Show Gist options
  • Select an option

  • Save Crocoblock/7ae55e3b2e751580d6a07a5271fee139 to your computer and use it in GitHub Desktop.

Select an option

Save Crocoblock/7ae55e3b2e751580d6a07a5271fee139 to your computer and use it in GitHub Desktop.
JetEngine / Queried Term (Option fallback) macro
<?php
add_action( 'jet-engine/register-macros', function(){
class JEC_Queried_Term_Option extends \Jet_Engine\Macros\Queried_Term {
/**
* Macros tag - this macro will look like %current_user_prop|ID% if typed manually
*/
public function macros_tag() {
return 'queried_term_option';
}
/**
* Macros name in UI
*/
public function macros_name() {
return 'Queried Term (Option fallback)';
}
/**
* Macros arguments - see this https://developers.elementor.com/docs/controls/regular-control/ for reference
* An empty array may be returned if the macro has no arguments
*/
public function macros_args() {
return array(
'option_name' => array(
'label' => 'Option name',
'type' => 'text',
'default' => '',
),
);
}
/**
* Macros callback - gets existing property from the current logged in user
*/
public function macros_callback( $args = array() ) {
$result = parent::macros_callback( $args );
if ( ! empty( $result ) && is_scalar( $result ) ) {
return $result;
}
$option_name = ! empty( $args['option_name'] ) ? $args['option_name'] : null;
$result = jet_engine()->listings->macros->do_macros( "%option_value|$option_name%" );
return $result;
}
}
new JEC_Queried_Term_Option();
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment