Creating a rotating header /image slider using theme customization

We can do that! First, you’ll need to add a custom section on the Theme Customizer, containing all the image uploads (we’ll use 3 for this example): add_action( ‘customize_register’, ‘themename_customize_register’ ); function themename_customize_register($wp_customize) { $wp_customize->add_section( ‘slides’, array( ‘title’ => ‘Slides’, ‘priority’ => 25, ) ); $wp_customize->add_setting( ‘first_slide’, array( ‘default’ => ”, ) ); $wp_customize->add_control( new … Read more

Permanently remove first image from posts

Just as @s_ha_dum suggests, you can loop through all of your posts and update the content of each one. The following gives you the idea but is untested: $posts = get_posts( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 500, ‘offset’ => 0, ) ); foreach( $posts as $post ): // Update each post with your reg-ex … Read more

Get attachment ID of author_meta image – Attachment Metadata

I suggest you to use the more newer media manager dialog; WordPress will hanlde all the image upload stuff, including generating intermediate sizes and attachement metadata. Here a working example (it is a quick example built from a previous code, it may needs some tweaks to be used on production): add_action( ‘admin_enqueue_scripts’, ‘load_wp_media_files’ ); function … Read more

How do you modify the HTML output of a Gallery item (using the gallery shortcode)?

Let’s assume that your theme is NOT rolling its own gallery shortcode, and let’s assume that you’re using the shortcode rather than the ‘gallery’ post format here. What you’re looking for is the ‘gallery_shortcode’ function within wp-includes/media.php around line 750 (as of 3.3.1). That’s where the HTML output of your gallery items is hard-coded. Of … Read more

How to reduce original image quality on upload?

In general I wouldn’t recommend modifying the original uploaded image files, just in case we might need to re-generate intermediate sizes. But let’s see if it’s possible 🙂 We can in general let WordPress choose the image editor, that depends on modules like GD or Imagick, through: $editor = wp_get_image_editor( $file ); but this can … Read more