Created
October 11, 2023 18:48
-
-
Save dantetesta/6a17bf2e3cba7feead8b7b440c82fa30 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
add_action( 'jet-engine/register-macros', function(){ | |
if ( ! class_exists( '\Jet_Engine\Query_Builder\Macros\Query_Results_Macro' ) ) { | |
return; | |
} | |
class Query_Results_Empty_Macro extends \Jet_Engine\Query_Builder\Macros\Query_Results_Macro { | |
public function macros_tag() { | |
return 'query_results_empty'; | |
} | |
public function macros_name() { | |
return 'Query Results (custom)'; | |
} | |
public function macros_callback( $args = array() ) { | |
$items = parent::macros_callback( $args ); | |
if ( ! empty( $items ) && is_array( $items ) ) { | |
$result = implode( ',', $items ); | |
} elseif ( empty( $items ) ) { | |
$result = ''; | |
} else { | |
$result = $items; | |
} | |
return $result; | |
} | |
} | |
new Query_Results_Empty_Macro(); | |
}, 999 ); | |
------------------- | |
Advanced Query adicione | |
SELECT ID | |
FROM {prefix}posts | |
WHERE ID IN ( | |
%query_results_empty|74%{"fallback":"0"}, | |
%query_results_empty|37%{"fallback":"0"} | |
) | |
ORDER BY FIELD( | |
ID, | |
%query_results_empty|74%{"fallback":"0"}, | |
%query_results_empty|37%{"fallback":"0"} | |
) | |
sem informar o post usando advanced query | |
--------- | |
crie uma query com post id preserve | |
com post in puxando query results da primeira query | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment