• Resolved maxgx

    (@maxgx)


    i think a Slideshow column and filter would be useful in the Slides admin page.
    thanks to Justin Tadlock and Pippin i’ve added the following to the functions.php file of my theme to get it:

    /* Add "Slideshow" column in Meteor Slides slide admin */
    add_filter('manage_edit-slide_columns', 'my_columns');
    function my_columns( $columns ) {
    		$columns = array(
    
    			'cb'         => '<input type="checkbox" />',
    			'slide'      => __( 'Slide Image', 'meteor-slides' ),
    			'title'      => __( 'Slide Title', 'meteor-slides' ),
    			'slideshow' => __( 'Slideshow', 'meteor-slides' ),
    			'slide-link' => __( 'Slide Link', 'meteor-slides' ),
    			'date'       => __( 'Date', 'meteor-slides' )
    
    		);
    
    		return $columns;
    }
    
    add_action( 'manage_slide_posts_custom_column', 'my_manage_slide_columns', 10, 2 );
    function my_manage_slide_columns( $column, $post_id ) {
    global $post;
    switch( $column ) {
    
        /* If displaying the 'Slideshow' column. */
        case 'slideshow' :
    
            /* Get the taxonomy for the post. */
            $terms = get_the_terms( $post_id, 'slideshow' );
    
            /* If terms were found. */
            if ( !empty( $terms ) ) {
    
                $out = array();
    
                /* Loop through each term, linking to the 'edit posts' page for the specific term. */
                foreach ( $terms as $term ) {
                    $out[] = sprintf( '<a href="%s">%s</a>',
                        esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'slideshow' => $term->slug ), 'edit.php' ) ),
                        esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'slideshow', 'display' ) )
                    );
                }
    
                /* Join the terms, separating them with a comma. */
                echo join( ', ', $out );
            }
    
            /* If no terms were found, output a default message. */
            else {
                _e( 'No Slides' );
            }
    
            break;
    
        /* Just break out of the switch statement for everything else. */
        default :
            break;
    }
    }
    
    /* Add filter for Metero Slides slideshow taxonomy */
    add_action( 'restrict_manage_posts', 'my_add_taxonomy_filters' );
    function my_add_taxonomy_filters() {
    	global $typenow;
    	// an array of all the taxonomyies you want to display. Use the taxonomy name or slug
    	$taxonomies = array('slideshow');
    	// must set this to the post type you want the filter(s) displayed on
    	if( $typenow == 'slide' ){
    		foreach ($taxonomies as $tax_slug) {
    			$tax_obj = get_taxonomy($tax_slug);
    			$tax_name = $tax_obj->labels->name;
    			$terms = get_terms($tax_slug);
    			if(count($terms) > 0) {
    				echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
    				echo "<option value=''>Show All $tax_name</option>";
    				foreach ($terms as $term) {
    					echo '<option value='. $term->slug, $_GET[$tax_slug] == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>';
    				}
    				echo "</select>";
    			}
    		}
    	}
    }

    https://wordpress.org/plugins/meteor-slides/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add 'Slideshow' column and filter in Slides admin’ is closed to new replies.