• Hey Guys,

    I’m using Shortcodes Ultimate and Enhanced Media Library. I want to make a gallery based on the Media Library’s Media Categories, but this didn’t work. So I tried to figure out why it won’t work and played with the code. Now I want you to ask if you could change the official code so that it will work with the official version or if there is a reasion why you wrote the code that way.
    Here is my version of tools.php line 662 to 755:

    <?php
    public static function get_slides( $args ) {
    		(...)
    		// Source: taxonomy
    		elseif ( $args['source']['type'] === 'taxonomy' ) {
    			// Parse taxonomy name and terms ids
    			$args['source']['val'] = explode( '/', $args['source']['val'] );
    			// Taxonomy parsed incorrectly, return empty array
    			if ( !is_array( $args['source']['val'] ) || count( $args['source']['val'] ) !== 2 ) return $slides;
    			$query['tax_query'] = array(
    				array(
    					'taxonomy' => $args['source']['val'][0],
    					'field' => 'id',
    					'terms' => (array) explode( ',', $args['source']['val'][1] )
    				)
    			);
    			$query['post_type'] = 'attachment';
    			$query['post_status'] = 'any';
    		}
    		// Query posts
    		$query = new WP_Query( $query );
    		// Loop through posts
    		if ( is_array( $query->posts ) ) foreach ( $query->posts as $post ) {
    				// Get post thumbnail ID
    				$thumb = ( $args['source']['type'] === 'media' ) ? $post->ID : get_post_thumbnail_id( $post->ID );
    				$thumb = ( $args['source']['type'] === 'taxonomy' ) ? $post->ID : $thumb;
    				// Thumbnail isn't set, go to next post
    				if ( !is_numeric( $thumb ) ) continue;
    				$slide = array(
    					'image' => wp_get_attachment_url( $thumb ),
    					'link'  => '',
    					'title' => get_the_title( $post->ID )
    				);
    				if ( $args['link'] === 'image' || $args['link'] === 'lightbox' ) $slide['link'] = $slide['image'];
    				elseif ( $args['link'] === 'custom' ) $slide['link'] = get_post_meta( $post->ID, 'su_slide_link', true );
    				elseif ( $args['link'] === 'post' ) $slide['link'] = get_permalink( $post->ID );
    				elseif ( $args['link'] === 'attachment' ) $slide['link'] = get_attachment_link( $thumb );
    				$slides[] = $slide;
    			}
    		// Return slides
    		return $slides;
    	}
    ?>

    https://www.ads-software.com/plugins/shortcodes-ultimate/

  • The topic ‘SU Gallery with Enhanced Media Library's Media Categories’ is closed to new replies.