I created a function to retrieve attachment id from it’s src, might work in your case scenario as well
function get_attachment_id_from_src ($image_src) {
global $wpdb;
$id = $wpdb->get_var('SELECT ID FROM '.$wpdb->posts.' WHERE guid="'.$image_src.'"');
return $id;
}
Related Posts:
- get_pages() Returns Only One Item
- HowTo: Add wrapper to columns shortcode?
- Use html inside shortcode function
- Control the srcset much more (not all sizes in it each time)
- Check if the image size is available and if not use ‘full’ image size
- Way to store featured image width and height in two separate variables?
- Shotcode argument issues
- Shortcode parse error – wrong syntax
- Remove Custuomize Sections
- Exclude category from shortcode
- Can we create our own theme’s function.php?
- wp_nonce_field is breaking form for reasons unknown
- Define PHP variable from a seperate API if statement
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- Excerpt for pages not showing
- Function shortcode – Set Parameter
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Adding an option to a shortcode
- How to use author meta in shortcode?
- Using multiple line variable inside a function?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Use a shortcode to display custom meta box contents
- Echoing function into WordPress NextGen gallery
- Output loop to function return?
- How to echo the value of an array element using a function via a shortcode
- Wp-query Order By problem
- Does size of a theme’s functions.php file matter?
- Functions php shortcode for displaying main menu with no child items
- Shortcode Attributes to Return different $_POST
- get_next_posts_link() returns no result despite available posts
- Nav menus all outputting the same links
- PHP 7.1 | Warning: A non-numeric value encountered in
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- Woocommerce checkout field
- How to include any template using Shortcode fuction?
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- How to insert class in each list of categories?
- I can’t add CSS with functions.php
- Need to convert image url to a Base_64 data url with wordpress function..
- dynamic site link for future migration in echo do_shortcode()
- Getting the teaser text without overriding global variables
- Combine two active_callbacks into one on theme customizer
- How to create shortcode with html and php content?
- Tracking the number of shortcodes for a list?
- Need a method to prevent WP from adding in between my shortcodes
- WP Customizer API loaded into functions.php
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- Shortcode question
- call_user_func_array() expects parameter 1 to be a valid callback, function
- why can’t i add front.css to my frontpage.php
- Can I include a custom PHP function in a WordPress function?
- How to create a shortcode out of a php function
- “options.php” not found
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- Is this an acceptable practice for WordPress theme development?
- What is the correct way to include my new functions and scripts in WordPress?
- wp_nav_menu work in functions.php but not in the theme
- Shortcode to get featured image of specific id post
- Modify shortcode to work with custom post types
- shorthand syntax for custom fields
- Rewrite Question Mark in Post Template with URL Parameter for clean URLs
- contact form in template with jquery,validate and ajax
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Shortcode of a function
- show all the posts thumbnails
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- Problem with shortcode inside a shortcode
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Need help making a short code work
- Using One Function To Create Two Different Shortcodes
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- How to fix Function create_function() is deprecated in / themes
- Display a list of random terms from custom taxonomy with shortcode
- Exclude specific post from query
- Advanced method to control cache of enqueued style/script
- Load templates, pass arguments, and render output from functions.php
- How to add if statement on WordPress shortcode output
- Passing function arguments via a shortcode
- WordPress wp_dequeue_script remove all other scripts
- Pagination not working – FrontPage
- Customizing the wp_video_shortcode output with add_filter
- page shows short code not output
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- Probleme shortcode with list author
- How can I prevent a shortcode div from extending beyond its boundaries?
- Function to function shortcode help [closed]
- Last updated posts shortcode in functions.php
- Is_Page doesnt detect my page
- Test CDN link from function.php or wp_enqueue_script/style?
- I want to display the sku in the product pages of my EDD website
- How to customize archive widget only for cpt?
- wp_title() return random number
- Why does echo on functions.php not yield result in source code?
- Shortcode to output category description by passing ID
- Help using ShortCodes to style whole chunks of the post
- Shortcode to insert default text and change one word throughout it?