Tag Info

New answers tagged

3

I got curious about the SQL way of finding all posts without any attachments. Method #1 - Sub query with NOT IN Here's my first attempt to construct such a query: global $wpdb; $sql = " SELECT p1.ID, p1.post_title FROM {$wpdb->posts} p1 WHERE p1.post_type = 'post' AND p1.post_status = 'publish' ...


5

If you're comfortable with the complete opposite of the linked answer, you simply could use this query to fetch all posts that have an attachment and then use their IDs as the post__not_in parameter of \WP_Query: $attachment_args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => 'inherit', ...


0

There are two plausible answers. There is a good chance this is a restriction on the wordpress site settings. In multisite this is in: Network -> Settings: Upload Settings Site upload space: [checkbox] Limit total size of files uploaded to [xxx]MB. Default is 50MB. Unchecking this or increasing the limit should solve the issue. The side ...


1

I am also seeking the same solution. I am going to create a gallery filter function - an extension to this. Do you want to collaborate? function get_post_gallery( $post = 0, $html = true ) { $galleries = get_post_galleries( $post, $html ); $gallery = reset( $galleries ); /** * Filter the first-found post gallery. * * @since 3.6.0 * * @param array ...


0

Deleting images using plugin: You can use this plugin, it will search your database and look if image is inserted into any post (in content, as featured image, in any custom field, anywhere...) or as background... If image is not used anywhere it will give you option to delete it. You will get list of all images on your site not used anymore, so you can ...


1

You have a limit inside an script and you should change some values to adapt your needs: jQuery.... //user settings var thumbsPerPage = 15; var maxPaginatedLinks = 200; var hideEffect = "drop"; var showEffect = "drop"; var effectSpeed = "slow"; var count = 1; //handles multiple galleries on page var galleryCount = $( "[id^=gallery-]" ).each( function() ...


0

I just fixed this after several hours of research. If one need to do the same thing, he must edit file wp-includes\js\media-views.js and replace add with unshift in this line (#2611, galleryAddToolbar): edit.get('library').add( state.get('selection').models ); So the code will look like this: edit.get('library').unshift( state.get('selection').models ); ...


1

You can override the gallery shortcode link attribute with: add_filter( 'shortcode_atts_gallery', function( $out ){ $out['link'] = 'file'; return $out; } ); This means that even if your shortcodes are: [gallery ids="1,2,3"] [gallery ids="1,2,3" link="none"] the gallery output will always be generated as if you used link="file". ...


0

The answer was to assign a count to each attachment: $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID, 'order_by' => 'menu_order', 'order' => 'DESC' ); $attachments = get_posts( $args ); if ( $attachments ) { $count = 0; foreach ...


0

i'm usig the code for create a link (next and prev) $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) ); foreach ( $attachments as $k => $attachment ) : if ( ...


0

I think one good possibility is to add a endpoint to permalink for galleries and then check the template to include in the template_include filter: add_action('init', function() { add_rewrite_endpoint( 'gallery', EP_PERMALINK ); }); add_filter( 'template_include', function($template) { if ( get_query_var( 'gallery' ) ) { return ...



Top 50 recent answers are included