Search
 
SCRIPT & CODE EXAMPLE
 

PHP

what-is-diference-wp-get-attachment-url-wp-get-attachment-src-get-post-thumb

wp_get_attachment_url($id)

Returns a full URI for an attachment file or false on failure. Here id is attachment post id

Example

echo wp_get_attachment_url( $id ); 
echo wp_get_attachment_url( 12 );
$example_url = wp_get_attachment_url( get_post_thumbnail_id() );
echo '<div style="background-image:url('.$example_url.');"></div>';
wp_get_attachment_image_src()

return array value of image attribute

Example

wp_get_attachment_image_src( int $attachment_id, string|array $size = 'thumbnail', bool $icon = false )

$image_attributes = wp_get_attachment_image_src( $attachment_id = 8 );
if ( $image_attributes ) : ?>
    <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" />
<?php endif; ?>
get_post_thumbnail_id() return featured image id

Example:

get_post_thumbnail_id($post_id)
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
Comment

PREVIOUS NEXT
Code Example
Php :: $this-uri-uri_to_assoc(5); 
Php :: old codestar textarea field 
Php :: function placing bet in guide using php 
Php :: merge cell collumn phpOffice 
Php :: 279.00 to php 
Php :: ubuntu add phpstorm to launcher 
Php :: How To Substract And Add Hours In Laravel Using Carabon? 
Php :: php decrement variable by 1 
Php :: woocommerce create client account without email 
Php :: laravel windows stop serving 
Php :: wp-query 
Php :: php check how long a function took to exexute 
Php :: php array_walk_recursive 
Php :: ?id=$1&user=$2 
Php :: get average of sql column php 
Php :: SET DEFAULT hide title astra wordpress 
Php :: remove public laravel 
Php :: vscode php debugger change value 
Php :: building an ecommerce website with laravel 
Php :: carbon get difference between two dates in years and months 
Php :: Multi-idiomas com PHP 
Php :: Required parameter follows optional parameter (500 Internal Server Error) php 
Php :: ci4+ connection code 
Php :: WooCommerce: Add Content to a Specific Order Email 
Php :: how to run php code in cmd 
Php :: Number in English Words (Indian format) php 
Php :: laravel add model to one to many relationship 
Php :: laravel cors 
Php :: number to words gujarati php 
Php :: how to access session value passed to sub domain 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =