Limit dimensions of “Full” size images

So I’ve found this WP_Image_Editor in the CodeX. Basically by adding the code below it should automatically resize an image 🙂 Code: $image = wp_get_image_editor( ‘cool_image.jpg’ ); // Return an implementation that extends WP_Image_Editor if ( ! is_wp_error( $image ) ) { $image->resize( 300, 300, true ); $image->save( ‘new_image.jpg’ ); } I don’t know exactly … Read more

Displaying text if post was within 5 hours

human_time_difference() will not work here as it returns a string in a human readable form. However, we can use some of the logic used there to construct a workable function You can try the following: (Untested) function get_custom__time_diff() { global $post; // Get the current time $current_time = time(); // Get the post date $post_date … Read more

Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?

I think you are looking for this- function star_rating( $atts ) { $max = 5; $atts = shortcode_atts( array( ‘grade’ => $max, // default ), $atts ); $star_icons=””; $full_star = floor( $atts[‘grade’] ); for( $i=1; $i<=$full_star; $i++ ) { $star_icons .= ‘<i class=”fa fa-star”></i>’; } $half_star = 0; if( (int) $atts[‘grade’] != $atts[‘grade’] ){ $half_star … Read more

Adding bootstrap classes to video shortcodes

This is how I bootstrapped youtube embeds in one of my projects. /** * Responsive Youtube embeds. */ add_filter( ’embed_oembed_html’, function( $html, $url, $attr, $post_ID ) { if ( false !== stripos( $html, ‘<iframe ‘ ) && false !== stripos( $html, ‘.youtube.com/embed’ ) ) { $html = sprintf(‘<div class=”embed-responsive embed-responsive-16by9″>%s</div>’, $html ); } return $html; … Read more

Limit Taxonomy Output in Conditional Statement

Samuel Elh correctly answered this. if ( $type === ‘portfolio’ ) { $terms = get_the_term_list( $post->ID, ‘royal_portfolio_cats’, ”, $separator ); $term_array = explode(‘,’,$terms); if ( $limit = array_slice($term_array, 0, $max = 5) ) { echo implode( “, “, $limit ); if ( count( $term_array ) > $max ) { echo “…”; } }; }