You cannot insert remote file in this manner.
<?php wp_insert_attachment( $attachment, $filename, $parent_post_id ); ?>
$filename (string) (optional) Location of the file on the server. Use
absolute path and not the URI of the file. The file MUST be in the
uploads
https://codex.wordpress.org/Function_Reference/wp_insert_attachment
You should first download it to temp dir.
If you wish to keep files on your CDN and simply save URI, consider adding a custom field and saving it there.
Related Posts:
- Loading template files from a subfolder in my theme?
- Display a different theme for not logged-in users
- How can I show more than 15 themes at a time in the admin menu?
- How to trigger function on theme delete?
- Make it possible to pick a color theme for specific pages
- OptimizePress Theme Overriding add_filter page_template
- Execute filter in theme as last
- How can I add class to every quote element?
- How to display message (with switch_theme hook) after deactivating My theme?
- What hook is the currently active theme’s functions.php file loaded on? [duplicate]
- after_setup_theme is called three times
- It’s okay if I do not write add_action()
- Posts as filtered list – expandable
- Using filter in the widget causes fatal error
- Fix warning: Missing argument
- Set custom directory in theme for page templates
- Webflow Interactions on WordPress site?
- Are immediately-called actions not usable in themes?
- Firebug and Chrome rendering two body tags
- Adding a wp_head hook from an included PHP file
- Hooking/Filtering theme name to add theme directory
- Fatal error Class-wp-hook, again, but not sure what’s triggering it
- How to set thumbnail image for a (child) theme
- Categorising themes by folders in backend
- Edit plugin without hooks in functions.php
- Is it possible to stop a theme activation when a certain plugin is not activated
- apply_filters() slices away needed arguments
- WordPress themes under GPL license
- Is it possible to Hook/Filters Attachment Creation?
- How to hook some Unicode texts into calendar widget safely?
- How to add attributes to tag when template cannot be directly modified
- How can I customize the search results in Bones theme?
- How to develop a theme while having another show up
- How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
- How to load a different theme for categories?
- Can I update themes without enabling maintenance mode?
- How to change sidebar per page?
- Add a series of checkboxes to theme options
- WordPress Theme Development Seemingly Awful Partitioning of Includes?
- Disable Theme API / Front end (for API only environment)
- Hide default “Recent Comments” Widget if there are no comments yet
- Showing post thumbnail (attachment) on the archive.php category listing
- How to change the order of HTML output of a core block?
- Theme Check warning wrong direcory for theme
- Add more widget areas to a theme
- Posts and Pages not showing on admin, but showing in theme
- Hooking in to replace the Sidebar/Widget areas
- Looking for a fully customisable WP responsive theme to develop a small scale fiverr type site for voice artists [closed]
- Page dissapears when i click save
- How to use command lines an activate theme in wp – cli also setup Vagrant/Sage Theme?
- Is wordpress big enough for my project [closed]
- How to get theme screenshot
- i would like to have 3 default columns editable in guttenberg
- Define theme information other than through style.css
- Change avatar on themed profile page
- How to get menu location in wp_update_nav_menu hook
- WordPress 5.1 upgrade has lost the parent theme JavaScript
- Is it possible to open a page with a different theme?
- comment_for() Custom fields not visible when user is logged in
- Create page options for theme?
- Where is the best place to catch useragent?
- Knowing blog name using blog id
- Alternative to Back End Dashboard?
- How can I change the prev / next buttons text to Dutch?
- Woocommerce single product image blurred and small. Actual image is big
- Adding a template in WPTouch
- Are the Theme frame works or Theme builders slow downs the performance? [closed]
- Make the “Add New Post” one column for all users
- What happened to my Inactive Widgets?
- BuddyPress – A hook available to hide custom born date on public profile view?
- WP Nanoplex 1.0.3 malfunction
- Cannot change WordPress site title on a staged site
- How to add image from theme files to media library after theme activation?
- How to download my custom theme?
- How to get title of images in post content
- Understanding the child / parent theme relationship
- Add Index to Item in WordPress Gallery
- Dynamic image for Jumbotron on WordPress Custom Theme
- How to implement theme option to change bootstrap 4 container from .container to .container-fluid
- use a Thumbnail size in post
- Transfer WordPress site to another domain
- 500 Internal Errors
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Strange Theme Error – parent style occasionally showing though child theme
- wp_editor customization
- Passing a parameter to filter and action functions
- How might one programmatically set the link for all images in all posts?
- change attachment custom field onChange event
- Does WordPress provide themes_api function?
- Where do URI files come from?
- How to show tags in posts with a theme that does not do it
- Converting HTML5 to XHTML
- How to remove header “ish” label [closed]
- How do you disable the verification process of user email changes?
- File execution order
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- How to add color icons to front of custom block color palettes
- Change social icon in twenty twenty three theme
- Custom Theme Additonal CSS “” are transformed to “>” and “<”
- Add button and title on submenu WordPress