Limit amount of results returned

$images = $wpdb->get_col(” SELECT ID FROM $wpdb->posts WHERE post_type=”attachment” AND ID in ($meta) ORDER BY menu_order ASC LIMIT 5 “); Like @Kaiser suggested you can specify a range (5th to 20th results, a total of 15 results are returned at max) like this: $images = $wpdb->get_col(” SELECT ID FROM $wpdb->posts WHERE post_type=”attachment” AND ID in … Read more

Link Featured Thumb to Attachment Page, If Possible

Question 1: How do you link Featured Image to its Attachment Page In the loop: <?php if( has_post_thumbnail() ) : ?> <a href=”https://wordpress.stackexchange.com/questions/52394/<?php echo get_attachment_link( get_post_thumbnail_id() ); ?>”> <?php the_post_thumbnail(); ?> </a> <?php endif; ?> Question 2: Post Format Templating Post formats are actually just a custom taxonomy with a fancy UI. Hence, you should … Read more

wp_insert_post featured image from library

You can use the function set_post_thubmnail(). After you inserted your post, just call this one, and you are ready to go. $yourpostid = wp_insert_post( $args ); // Define the post in the args first set_post_thumbnail( $yourpostid, $thumbnail_id ); // set the ID of your thumbnail to be the featured image of your newly created post.

How to grab the first two image attachments from a post?

Looks like you may have just not had a loop setup, try this one <div class=”two_images”> <?php global $post; $args = array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘numberposts’ => 2 ); $images = get_posts($args); if ( $images ) { $i = 0; while($i <= 1){ … Read more

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