How to display a thumbnail of a post with a background image

How to display a thumbnail of a post with a background image

Wordpress

To display a thumbnail of a post as a background image, it is sufficient to use the following code:

<?php
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_object = get_post($thumbnail_id); 
echo ($thumbnail_object->guid); ?>

This code gets the URL of the attached image. On an example it looks like this:

<div class="background" style="background: url(' <?php
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_object = get_post($thumbnail_id); 
echo ($thumbnail_object->guid); ?> ')">

The code is basically suitable for entries, pages, products and product categories.

FAQ

Common questions about WordPress project work and ongoing support.

What kinds of WordPress sites do you work with?

I work with business WordPress sites, WooCommerce stores, and projects that need to grow step by step — without unnecessary complexity or fragile solutions. This includes both new launches and existing sites that need refinements, support, or careful technical updates.

Can you improve an existing site without a full redesign?

Yes. Most tasks involve sites that are already live: new sections, functional improvements, WooCommerce changes, performance optimisation, or technical fixes. The goal is for the site to stay stable, manageable, and easy to develop further.

What types of tasks do you take on most often?

Most often this is custom WordPress development, Figma design implementation, WooCommerce refinements, support for live sites, fixing technical issues, and practical improvements over time. In selected scenarios I also help with light AI automations for content, enquiries, or internal admin workflows.

Do you work on WordPress speed and performance?

Yes. WordPress optimisation usually involves reviewing the theme, plugins, images, fonts, page structure, and the site's overall technical neatness. The aim is not a "magic button", but practical changes that make the site faster and easier to maintain.

Do you use AI when working on WordPress sites?

Yes, but only where it genuinely helps the process. AI works best for content drafts, FAQ or support assistants, enquiry handling, and small automations around an existing WordPress site. The approach is simple: AI should reduce routine work, not complicate the site.

What do I need to prepare to discuss a task or project?

Usually a short description of the site, the task, the desired outcome, and examples or technical constraints if you have them is enough. If the project is already live, it also helps to share the current site or a staging environment — this makes it easier to understand the scope of work.

Can I get in touch not for a new site, but for support or specific improvements?

Yes. I work not only on new builds, but also on live sites that need to be maintained, fixed, and improved gradually. This can include new pages, admin changes, WooCommerce refinements, small UX improvements, or technical maintenance.

Need help with a WordPress project?

If you need custom WordPress development, design implementation, or support for an existing site, I would be happy to review the project.