Image with description side by side

Yes, I think this is a great, fundamental question of WordPress editing and content creation by low-level users who are met with the big blank editing area and don’t know how to wrangle html. There are myriad answers: hardcore coding, softcore coding, plugins and everything in-between. The answer for me is Advanced Custom Fields. I … Read more

Editing built in Gallery shortcode to filter by categories

There are various ways to run another WP_Query with a tax query and collect the ID’s into the include attribute of the gallery shortcode. Let’s try another approach, without running a secondary WP_Query. Native gallery: Support taxonomy and term attributes We introduce the following custom gallery shortcode attributes: Here’s a demo plugin that supports that … Read more

How to prevent resized featured images?

Featured image sizes are mostly likely controlled by your theme, so I would look there. Maybe there is a theme setting for it. You can also check the following setting to see if it us using one of those sizes. You can change the featured image size by adding this code into your functions.php file. … Read more

Can’t access ‘Store uploads in this folder’

This is a very good question. The answer to the referenced post requires a change to the WP options. They are stored in the database in the wp_options table (assuming wp_ is your prefix). There are a few ways to change these in this case: Direct DB access: if you’re comfortable modifying the WP DB … Read more

How to make programmatic image upload generate thumbnail and sizes?

In order for wp_generate_attachment_metadata() to work properly in that it creates a thumbnail and other intermediate/image sizes like medium and large, the image attachment/post data must have the proper MIME type (post_mime_type), and despite you did set it in your $attachment array (the post data), there’s a problem with this part in your code: $wp_filetype … Read more

Include captions

st Note: // Prepare the code for safety $images = $wpdb->get_col( $wpdb->prepare( ” SELECT ID FROM %s WHERE post_type=”attachment” AND ID IN ( %s ) ORDER BY menu_order ASC “, $wpdb->posts, $meta ) ); nd Note: Look into what you already got: // Inside the foreach loop echo ‘<pre>’; var_dump( $att ); echo ‘<pre>’; rd … Read more

Query for recent images across multiple posts

You can use get_posts or create a new WP_Query using the following args (or something similar). <?php $args = array( ‘post_type’ => ‘attachment’, // attachment post type ‘post_status’ => ‘inherit’, // all attachments have this post status ‘post_mime_type’ => ‘image’, // make sure you get images only ‘posts_per_page’ => 5 // however many images you … Read more

Randomly add a ‘ul’ list of images

Adding the following to your theme’s functions.php file will let you use a shortcode ( [wpse73055-random-images] ) with an optional num parameter (i.e. [wpse73055-random-images num=5] to display 5 random images). function wpse73055_get_random_images( $atts ) { extract( shortcode_atts( array( ‘num’ => 10 ), $atts ) ); $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ =>’image’, ‘post_status’ => … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)