REST API to get Media by Taxonomy
-
For those who need a rest API to make a query to get media by taxonomy and term.
// Install https://www.ads-software.com/plugins/media-library-assistant/ // Install https://www.ads-software.com/plugins/insert-headers-and-footers/ function images( object $args ) { // This plugin requires MLA if ( ! class_exists( 'MLAData', false ) ) { return "MLAData does not exist"; } try { $per_page = $args['per_page']; $current_page = $args['current_page']; return MLAData::mla_query_list_table_items($_REQUEST, (( $current_page - 1 ) * $per_page ), $per_page); } catch (Throwable $e) { // For PHP 7 return $e->getMessage(); } catch (Exception $e) { // For PHP 5 return $e->getMessage(); } return "Empty"; } add_action( 'rest_api_init', function () { register_rest_route( 'mla_rest', '/images', array( 'methods' => 'GET', 'callback' => 'images', ) ); } );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘REST API to get Media by Taxonomy’ is closed to new replies.