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

WordPress 3.0テーマでカスタマイザーを有効化する方法

WordPress 3.0では、WordPressテーマのカスタム背景という新機能が導入されました。この機能により、ユーザーは自分のサイトにカスタマイザーを追加することができ、ブログやサイトにユニークなタッチを与えることができる。この機能はコアに追加されていますが、テーマがサポートしている場合にのみ有効化されます。この投稿では、WordPress 3.0用のWordPressテーマでカスタマイザーを有効化する方法を紹介します。

注:この投稿はテーマデザイナーに特化した中級レベルの記事です。

更新:動画で使用したadd_custom_backgroundのコードは削除されました。この投稿の下のコードを見てください。

動画

テキストチュートリアル

functions.phpファイルを開き、以下の行を追加するだけです:

[cbk1]

その後、外観の下にカスタマイザーのオプションが表示されるはずです。

Custom Background in WordPress 3.0

WordPress 3.0のデフォルトの20 10テーマには、すでにこの機能が有効化されています。

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

アバター

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.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

26件のコメント返信を残す

  1. bb

    Thank you Syed, this tweak just save me some thousand naira! Cheers.

  2. Stepan Vich

    Hi, Is there the possibility to add some field settings via add_settings_field function ??

  3. Michael

    This has been depricated. Here’s the new code:

    add_theme_support(‘custom-background’);

  4. Editorial Staff

    Very certain that you can use custom fields to change the background on each post / page if you want.

    管理者

  5. Abhimanyu

    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?

  6. The Raptor

    Thank you for this. Implementing it wa actually much more simple than I initially thought

  7. John

    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

      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.

      管理者

  8. chartinael

    My custom background section doesn’t have the display options. I installed 3.01 virgin.

  9. aleksander

    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

  10. Lane

    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…

  11. Ed

    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.

    • Editorial Staff

      Its a plugin in our Recommended Plugins list. Go to our homepage and look there. :)

      管理者

  12. Ed

    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.

  13. Pete

    Do you know how we do the custom header image as well?

  14. gifer

    hey thanks,btw is there any demo of it ?

  15. Pete

    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

      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.

      管理者

  16. Dustin Goerndt

    Radical! I wonder, can these be done per post or page?

    • Editorial Staff

      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.

      管理者

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。