Tag Info

New answers tagged

0

Use previous_image_link and next_image_link in a image.php or attachment.php file. <nav id="image-navigation" class="navigation image-navigation"> <div class="nav-links"> <?php previous_image_link( false, '<div class="previous-image">' . __( 'Previous Image', '$text_domain' ) . '</div>' ); ?> ...


0

Use a date query to get the next and previous (attachment) post by date. And exclude all child attachments from the current parent post. <?php // use in template for single attachment display // get all children ids (to exclude from the queries for next and previous post) $args = array( 'post_status' => 'inherit', 'post_type' => ...


2

With wp_get_attachment_image_src you get a array with values corresponding to the (0) url, (1) width, (2) height, and (3) scale of an image attachment (from the wordpress doc). you code can be: if($imageid){ $image_attributes = wp_get_attachment_image_src( $imageid, 'custom-size-01', false); echo "<img src=\""; echo $image_attributes[0]; echo "\" ...


0

Based on @Rarst his answer, I've created the following workaround. An additional field created_on should be added to a users' metadata upon creation. This is to identify the subdomain the user was created on and where the profile image might reside. So add this to your code ;) Place this function in a file where you get your user data or the ...


1

wp_get_attachment_image_src() takes ID of attachment "post type" (in quotes because it's native WP post type so not quite same thing as CPT). Now while users are shared in multisite, posts are not. The ID (94) that points to specific attachment in your main site has no meaning whatsoever in any other site of your multisite. At which point it boils down to ...


0

It's more a programming question, but try this: $post = get_post( get_post_thumbnail_id() ); if ( !isset( $post->post_title ) ) { echo 'Sorry no title'; } else { echo $post->post_title; }


0

Use if statements. if($caption = get_post(get_post_thumbnail_id())->post_excerpt){ echo $caption; }else{ //echo something else }


3

You can use get_attached_file() to: Retrieve attached file path based on attachment ID. And get_post_thumbnail_id() to determine the post thumbnail of the current post, or any post if you set the $post_id parameter. Exemplary usage: $bytes = filesize( get_attached_file( get_post_thumbnail_id() ) ); Use size_format() to ...



Top 50 recent answers are included