I am not sure where you are trying to do this but give something like this a try.
<?php
$category_id = 45;
query_posts('showposts=1&cat=".$category_id);
if (have_posts()) : while (have_posts()) : the_post();
$backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "full' );
endwhile; endif;
wp_reset_query();
?>
Related Posts:
- How to split the categories of subcategories with thumbnails
- Implementing a tricky wordpress menu (nested categories + thumbnails)
- Remove product category placeholder image (Woocomerce)
- Change thumbnail image depending product category
- Custom Walker for wp_list_categories
- How to change the thumbnail size to a specific category?
- Thumbnail for categories / taxonomies plugin?
- how to nest specific category thumbnails inside different containers
- How can i display category title over thumbnail?
- How to add a custom thumbnail size for a specific category?
- Could not insert term into the database
- Activate Gutenberg in category-descriptions
- How can I get category ID by category name?
- How would I increase the Author Role to be able to add a new category?
- Randomise results from a category page?
- Adding Custom User Profile data based upon Categories
- Only show category to certain user levels without plugin
- How to: 301 Redirect /category/ to /customname/
- Custom Query to search through categories
- Order posts by category name
- How can I make wp_list_categories output li with category-slug as class, for its children?
- Get sticky post from category?
- Remove word “Category” from WooCommerce product page [closed]
- Output link to category from WP_Query loop of woocommerce products
- Display name of the last child category
- If in category to be inside of a function
- How to exclude posts from a category when using this particular format
- Viewing category pages without the word ‘category’ in URL
- Different excerpt styles per category, but chronological
- Show only one category
- Pagination Not Working on Category.php page
- How to view WordPress’ default category IDs?
- Random taxonomy category list
- Broken category pagination
- Color different for the current category
- how to change template?
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Product Category WooCommerce
- Hard coded main navigation
- one category template for multiple categories
- Display posts separated by Category in Author’s page
- How can I define a custom archive for childs of a specific category?
- Category shows only top level child categories
- The arrangement of categories always change while posting article
- REST API: Display Category names in JSON?
- List posts in alphabetical order
- Where is the category of a post stored?
- Categories list loop – add separator every 3 categories [closed]
- wp_list_pages() exclude category
- How to define multi categories posts number
- Get the ID of 10 Latest Pages stored in a WordPress Category
- Admin: Navigation Menus do not show empty categories/taxonomies in the list’s search tab
- getting post data in functions.php
- how to separate categories in loop.php?
- How can i remove the posts category class names from body_class
- Different Category Headers using in_category and elseif
- Remove the number of posts displayed in wp_list_categories()
- related articles using shortcodes
- “Virtual category page” based on a custom field filter
- How to Sync Menu, Widgets and other masters from Main Website to its Sub Site
- Show category meta in loop on homepage
- How to get selected taxonomy or category ID if using custom walker?
- How to hide widget from certain category
- Category link redirect to custom template page instead of index.php?
- Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?
- the_category() doesn’t working in wp_query loop
- Displaying links to all posts of the same category on the post page
- handling the featured category
- Add class to current post in query_post
- separate posts to have (kind of) 2 blogs?
- create relationship between posts from one category and posts from another category
- Sort posts by child category name
- Intermittent Gutenberg 504 Gateway Timeout when calling REST route to retrieve categories
- display specific category when website loads
- Excluding current category from sidebar’s post widget, elementor, query-id
- OK to redirect the root WordPress category slug?
- Show subChild categories
- Automatically add custom taxonomy to posts in a category
- WooCommerce REST API not returning the default products category
- Category page 404s on mobile but not desktop?
- I want to create a custom taxonomy page showing a list of subcategories
- Displaying data from custom fields on a specific category page
- Get WooCommerce product category list in functions.php
- Include a page’s “category” in its URL
- Excluding specific category from custom theme functions
- Using the slug of a custom post category as prefix for the underlying custom post slugs
- How to define a post category undeletable by other users?
- Show Subcategory Name Instead of Parent Category
- Get category id of next / prev post inside the_post_navigation
- Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags
- Adding relevant categories to related post
- Code to display category-specific single.php is overriding normal single.php, too
- How can I add a Categories page link to a menu? [closed]
- Media Library filter returns undefined function get_current_screen
- Custom built theme won’t filter categories
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- get IDs from links categories
- get posts from 2 categories. (2 posts)
- Display all subcategories for a product category in woocommerce
- Why does my WordPress index has a category?
- Custom EndPoint not working when strip child category in URL