Query for post meta keys _wp_attachment_is_custom_background or _wp_attachment_is_custom_background:
function t5_bg_img_id()
{
if ( ! $bg_img = get_background_image() )
return FALSE;
$query = array(
'post_type' => 'attachment',
'fields' => 'ids',
'meta_query' => array (
array (
'key' => '_wp_attachment_is_custom_background',
'value' => get_option( 'stylesheet' ),
'compare' => '==',
),
array (
'key' => '_wp_attachment_metadata',
'value' => basename( $bg_img ),
'compare' => 'LIKE',
)
)
);
if ( array () === $bg_post = get_posts( $query ) )
return FALSE;
return $bg_post[0];
}
Related Posts:
- make WordPress image captions responsive
- Responsive Theme Design: how have slideshow on desktops/tablets and static photo on mobile using same template?
- Pb with responsive image sizes in WP 4.4
- Change function in responsive theme
- $content_width for responsive UI
- How do I make featured images retreived by the_post_thumbnail() responsive?
- GIF featured image is resized on server but not used in frontend. Why?
- Responsive 2 column staggered layout client expectations vs reality problem
- Responsive Video Max-width
- How to force the twentyfourteen narrow screen layout to apply to wide screens?
- twentythirteen h1 and h2 not resizing responsively
- YouTube video goes over sidebar [closed]
- Wp_List_Table not responsive
- mobile vs responsive sites [closed]
- Responsive Theme Design: how have slideshow on desktops/tablets and static photo on mobile using same template?
- responsive not working
- I want to add “View Desktop Version” for mobile visitors for my wordpress site
- Navigation Menu Rendering Issue on Windows 10
- Header Logo Scaling
- nextgen pro horizontal filmstrip moves up as browser narrows
- The hyperlink not responsive with post? [closed]
- Create various image sizes ad hoc
- Removing backstretch image from pages/posts
- Trouble with responsivitizing my twentythirteen header
- site is loading fully zoomed in on mobile devices
- Problems Replacing Background Color with Static Background Image in Responsive Design
- Show content based on width?
- making images scalable for responsive designs [closed]
- Is Twenty Eleven Theme Responsive ? any update? [closed]
- How I can add responsive font size in theme.json file
- Proper usage of wp_is_mobile()?
- WP 4.4. responsive images browser choosing the “wrong” one
- How to insert pictures without hard coded dimensions?
- How-to make the admin area mobile friendly [closed]
- Images all broken after migration and upgrade
- Add custom background to div in home page
- WP 4.4 aspect ratio with responsive image
- Benefits of storing uploads in an assets folder?
- Don’t load scripts if on mobile/tablet
- Change theme based on window size
- Run shortcode at certain resolution
- Get a list of all image sizes that match aspect ratio of original one
- What controls responsiveness in WordPress?
- Removing height and width from images with a caption
- Why does my caroussel gallery do this in responsive? [CSS] [closed]
- Best practice for query_posts in responsive design?
- Twenty fifteen theme – change responsive menu condition
- Custom Background not Appearing
- Using SRCSET with Images and Featured Images
- Display Authors in a grid loop
- Old Site displays on Mobile View, not New Site
- Responsive menu gone on wordpress Responsive theme
- Implementing the twentythirteen responsive menu in twentytwelve
- Elements floating on top of each other when Resizing or checking site on mobile. Twenty Twelve
- No responsive design is displayed
- Custom Background by Page IDs
- Title has word broken when viewed in mobile [closed]
- Change background color of subpages
- I can’t change the body background-color through style.css
- Faster fonts on mobile
- HowTo: develop WP template with dynamic background image
- Add Image Size for Featured Image with Responsive Design
- Responsive dropdown menu with smaller screen sizes
- Placing background image over section divider
- How to select which thumbnails sizes are displayed in srcset
- Open Menu is not working in Mobile view [closed]
- Add custom background to section in home page
- Disable Media File Image Link On Mobile Devices
- Generate responsive post thumbnails of same size
- All 3?: Responsive resizing of images + image width of actual image for small images + max-width for all larger images
- Change the background of each post according to the category
- Custom Background default color not changing
- Restrict size of custom background image
- Background image no longer fits to screen now that project is in php files
- Need to make sidebar responsive only when screen width is greater than 1024px
- How to change the background color that appears at top when we pull down a website on mobile device?
- WordPress Responsive Image ( srcset ) not work properly
- Structuring Nav Menu and Background Custom page (Help)
- Twenty seventeen header is not responsive
- How to change background image
- Change background image page header overlay for each category
- WordPress Toggle Menu has stopped working
- How can I hide/show text only for mobile users?
- Website Tablet Check Out Field Issue
- @media applying globally and not separately for each screen width [closed]
- How can I disable Jetpack plugin on mobile?
- WordPress not choosing the right image from srcset
- Responsive Images in WordPress
- Different body image backgrounds on different pages, posts and categories
- Header formatting works for safari but not chrome @media screen size technique on iphone
- Bootsrtap.css overlap style.css in custom wordpress theme
- Is there a good way to use CMS images with CSS
- I would like to hide menu on desktop but still have it visible on small screen
- Correct way to make a custom block theme responsive
- Post interior margin in twenty eleven theme
- background not fixed and scaled on iPhone (but working on every other device)
- How to resolve status code: 410 from Pagespeed insights for the wordpress website
- Responsive rules with block themes and theme.json
- medium_large image size not displaying properly on the frontend?
- No src and sizes attributes present on WordPress thumbnail images; the smallest image size is loaded irregardless of viewport size