Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coppa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Come abilitare lo sfondo personalizzato nei temi di WordPress 3.0

Nota editoriale: guadagniamo una commissione dai link dei partner su WPBeginner. Le commissioni non influenzano le opinioni o le valutazioni dei nostri redattori. Per saperne di più su Processo editoriale.

WordPress 3.0 introduce una nuova caratteristica chiamata sfondi personalizzati per i temi di WordPress. Questa caratteristica darà all’utente la possibilità di aggiungere sfondi personalizzati al proprio sito che daranno un tocco unico ai loro blog/siti. Anche se questa caratteristica è stata aggiunta al nucleo, sarà attivata solo se il tema lo supporta. In questo articolo vi mostreremo come potete abilitare gli sfondi personalizzati nei temi di WordPress per WordPress 3.0.

Nota: questo articolo è di livello intermedio e si rivolge in particolare ai progettisti di temi.

Aggiornamento: il codice utilizzato nel video add_custom_background è stato eliminato. Guardate il codice qui sotto in questo articolo.

Video:

Testo-tutorial

Basta aprire il file functions.php e aggiungere la riga seguente:

add_theme_support('custom-background');

Alla voce aspetto dovrebbe essere presente un’opzione per gli sfondi personalizzati.

Custom Background in WordPress 3.0

Il tema predefinito twenty ten per WordPress 3.0 ha già abilitato questa caratteristica.

Divulgazione: I nostri contenuti sono sostenuti dai lettori. Ciò significa che se cliccate su alcuni dei nostri link, potremmo guadagnare una commissione. Vedi come WPBeginner è finanziato , perché è importante e come puoi sostenerci. Ecco il nostro processo editoriale .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Il kit di strumenti WordPress definitivo

Ottenete l'accesso gratuito al nostro kit di strumenti - una raccolta di prodotti e risorse relative a WordPress che ogni professionista dovrebbe avere!

Reader Interactions

27 commentiLascia una risposta

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Abhimanyu says

    There seems to be a problem. Just as I select the image file and click upload, it refreshes the page with no result. The ‘color’ thing works. And, I have tried many browsers.

    Any help? Can we do it manually? As in, by some codes?

  3. John says

    What is the default size for wordpress backgrounds? i.e. what size should images be for them to fit properly in the background.

    • Editorial Staff says

      The best image is the one that can be repeated, so you keep the page load time small. WordPress will only show the background image that fits the screen resolution of the user.

      Admin

  4. aleksander says

    Same situation here:
    Fatal error: Call to undefined function add_custom_background() in /mnt/data/www/sinya/aleksander.hu/i.aleksander.hu/wp-content/themes/stylize/functions.php on line 34

    what to do?
    haven’t upgrade yet to 3.0.0

  5. Lane says

    Hey I did what you said but i got this message

    Fatal error: Call to undefined function add_custom_background() in /home/patina/ilovepatina.com/wordpress/wp-content/themes/default/functions.php on line 2

    And now it won’t let me sign in at all to even go into the admin.
    Any advice? I need help bad…

  6. Ed says

    Hey… that was cool. After my first comment, I am taken to a different page with more information about your website and commenting… how did you make that happen? Plugin?
    I’d love to know more.

  7. Ed says

    It is important to note that for this to work within a theme, you must add the wp_head() after your theme stylesheet link in the theme header. This new function adds blocks with the added color/background from within the wp_head() section, and if you call your stylesheet after the wp_head(), your stylesheet will override the custom background function.

    I am torn, as I tend to call my stylesheet after the wp_head() call so that I can override styles added by plugins. May need to make a separate stylesheet for plugin overrides to be called later in the header.

  8. Pete says

    So how does WordPress know how to change the background? What if my current theme already has some background css attributes? Which one over-rides the other?

    • Editorial Staff says

      Your current theme would have to be made compatible with this feature. This is article is for theme designers who are creating themes and want to get WordPress 3.0 features in it. You would have to add the function for body class. If WordPress see that someone has updated the Custom Backgrounds page in the admin panel, then it will be prioritized. Otherwise the default background that you specify in the css file prevails.

      Admin

    • Editorial Staff says

      With the default function NO. For that you are better of using a plugin (several exist). The way this function works is it adds styling to the overall body class, so it will be the same for the entire site.

      Admin

Lascia una risposta

Grazie per aver scelto di lasciare un commento. Tenga presente che tutti i commenti sono moderati in base alle nostre politica dei commenti e il suo indirizzo e-mail NON sarà pubblicato. Si prega di NON utilizzare parole chiave nel campo del nome. Avremo una conversazione personale e significativa.