First, you don’t need the URL but the server path to the file, you can get it with get_attached_file
function, passing any WordPress attachment ID as a parameter. Then you need to load the contents of that SVG file directly, via file_get_contents
function and echo it out to the page.
$thumbnail_id = get_post_thumbnail_id( get_the_ID() );
$thumbnail_path = get_attached_file( $thumbnail_id );
echo file_get_contents( $thumbnail_path );
Related Posts:
- Use Icomoon external svg file with
- Replace custom SVG icons in Twenty Twenty-One
- Setting $_SERVER[‘HTTPS’]=’on’ prevents access to wp-admin
- Check if a menu is empty?
- How To Make Connection To WordPress Data Base In A Plugin?
- WordPress Template Engine?
- Walker class: Problems with understanding how walk() method can be called without error
- How to get the post count for the last x days filtering by categories
- How to create shortcodes that pull custom field data from general settings
- Where exactly do I write define( ‘WP_DEBUG’, true ) in wp-config file
- How to display related posts from parent category
- Making a follow button, Ajax not talking to php
- get understrap pagination to work with custom query
- Replace existing content from specific WooCommerce admin orders list column
- How do I translate this string – PHP syntax question
- Using is_page() in functions.php not working at all
- #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- Warning when using
- How to break down importing of feeds
- How to override wp-admin styling
- WordPress shows registration link for non logged users
- How to get woocommerce cart content without an action?
- How to call function at the bottom of post using plugin?
- How can I resolve the php notice “Constant EMPTY_TRASH_DAYS already defined”
- Use wp_get_recent_posts with search term
- multiple if statements [closed]
- Escape post image attachments added to template
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Bridging TinyMCE js and WordPress PHP?
- Echo URL of large version of Featured Image
- Remove price from Woocommerce variable product dropdown menu
- WP dynamic featured image – Can’t get second featured image url
- Getting trackpacks/pingbacks for a post via wordpress?
- Why is my cookie not unsetting upon logout? [closed]
- Loop through categories and display posts title under each dropdown
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- How to remove role=”navigation” from all nav elements?
- How to change redirection route to a php page for making it only accessible by logged-in members?
- how to query a post based on previous page post ID
- How to use $_GET function WordPress backend
- How to set variable, pass it to a partial file and remove it after?
- is there a benefit in using a constant over get_stylesheet_directory_uri?
- wp_dropdown_pages auto submit
- Custom PHP App with a wordpress site
- How to use if statement in an array? [closed]
- How to check if a PHP string is different than meta field?
- How to loop through all the attached images in a post, and get their url one by one
- Use Tags to initiate Search
- Form Submission Not Working In Custom Theme
- Convert a string into a decimal number for use in query
- How to get specific attribute from DB
- customize woocommerce templates and display store on home
- Show metabox only for homepage
- Delete or edit postmeta with specific meta_key?
- Concatenate Custom Field Value & HTML Value
- How do I properly code my footer? See example
- Use of IF statement in Header file
- Kohana Frontend, WordPress Backend
- apply_filters with several different values?
- Advanced Query posts
- Triggering a timewall after X days
- How do you create a custom category widget that you can style?
- Add Custom Category Description When Empty
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- echo cutom css code to WordPress page template file ? is this safe?
- Custom plugin: how do I call a PHP file if settings option is set to true?
- PHP `iconv` not working inside a WordPress site
- How to make a “page-option” in WordPress
- Replacing entire tag with shortcode – JavaScript [duplicate]
- How do I visualize the author’s post from the front end?
- How to add a full working piece of website already coded, to a large scale Website design project?
- Query to show average # of months all accounts with specific role have been active
- Send email to users when they get new followers
- Conditionally change WordPress core language
- Remove item from post_meta array via AJAX
- Use PHP to inject HTML into before page renders?
- Query doesn’t display text data with apostrophes
- WooCommerce Custom Tab with ACF Repeater Field
- My WP Website Shows HTTP ERROR 500
- add menu page in loop menu order
- CSS loading as empty file in Custom Theme
- Calling WordPress hook from within a class: call to undefined function error
- soap request in wordpress for a fedex pickup request [closed]
- Dynamically Create Posts Via XML File
- pages disable after wordpress update
- How to only fetch certain Tag ID’s
- Create server side text from wordpress page
- How to set a cookie based on a page Get variable?
- Editing the contents of just one div on a page from wordpress
- Postmeta not saving
- How to change the menu color
- Display latest 5 posts on homepage
- Display Current Time using shortcode
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- Cannot install plugins or themes on new WordPress installation at Cloudways
- Custom WP LIST Table filter
- links Slick jS library using wp_enqueue_scripts not pulling
- How to run site locally after downloading database
- How to change shipping method title based on cart amount?