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 AJAX in shortcode
- Display random categories on the front page (Finding and Editing Theme Functions)
- How to get woocommerce inventory status [closed]
- How to add attributes to a shortcode
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- How to display random users with avatars
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Organize functions.php
- How to override functions.php in child theme?
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Add inline css to theme
- Shortcode with custom content attribute?
- Passing HTML in WordPress Shortcode arguments
- Dequeue script in template isn’t working
- Display a text message if the shortcode is found?
- Changing itemprop from logo to image on custom logo?
- Custom Shortcode, functions PHP WP_Query loop
- Super simple shortcode not working
- How to call custom function from functions.php in site-wide template files?
- Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]
- How to enable template page only for a post id page
- How to get specified parent page title in my function
- Trigger popup in a php if/else statement
- Possible to display shortcode based on the category?
- Shortcode pagination not advancing
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- Having issues with a foreach inside of a shortcode with ACF gallery
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- How to get the index number of the posts?
- How to filter $content in shortcode function
- enqueue styles for only mobile wp
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Display gallery on bottom after content
- Redirect to another page using contact form 7? [closed]
- WordPress Shortcode function display outside of widget
- Help With Creating Shortcode
- Check if the image size is available and if not use ‘full’ image size
- Shotcode argument issues
- Remove Custuomize Sections
- Exclude category from shortcode
- Can we create our own theme’s function.php?
- Adding an option to a shortcode
- How to use author meta in shortcode?
- Use a shortcode to display custom meta box contents
- Woocommerce checkout field
- Getting the teaser text without overriding global variables
- Tracking the number of shortcodes for a list?
- Need a method to prevent WP from adding in between my shortcodes
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- 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?
- 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
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Shortcode of a function
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- 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?
- Exclude specific post from query
- WordPress wp_dequeue_script remove all other scripts
- Pagination not working – FrontPage
- page shows short code not output
- How can I prevent a shortcode div from extending beyond its boundaries?
- Function to function shortcode help [closed]
- I want to display the sku in the product pages of my EDD website
- Why does echo on functions.php not yield result in source code?
- use add_action in a shortcode (gravity form – WordPress)
- Shortcode displaying outside the div [duplicate]
- Shortcode with pagination advancing multiple queries
- Get shortcode attribute value to another function
- Display list of pages that contain a certain string within the slug
- How To Show Shortcodes In WordPress Custom Fields?
- How to create admin ajax function for my contact form
- Class::$template_dir_path=get_template_directory();
- Can I use a function to return HTML and the result of another function?
- wordpress not calling peliegro functions.php?
- Language switcher for subdomains
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Load a Child Theme’s style.css just before the closing tag
- How to display data from custom fields in my custom shortcode?
- Modify function Shortcode_atts
- restrict access to specific urls on a specific period of time
- Add title & subtitle to shortcodes
- Shortcode Variations?
- Add the title of a widget as an ID – for anchor links
- shortcode inside post called by ID does not render as expected
- Custom shortcode not being included in content paragraph [duplicate]
- Add custom css to theme
- Display function from functions.php in tag.php
- Passing postid of Testimonial Custom Post in Shortcode Parameter
- Creating mixture of shortcodes to use in the visual/text editor
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
- How to get postId from the argument $block when register_block_type()?
- WordPress is adding pagination for all pages not only for blog page, How to remove pagination for all pages except blog/posts page?
- Setcookie not setting cookies anywhere except admin