WordPress.org

Ready to get started?Download WordPress

Forums

Help with setting defaults in wp_options for clients theme (2 posts)

  1. cjchamberland
    Member
    Posted 1 year ago #

    I'm sure someone with tons of WP development experience can help me out. I have a client that has a custom wp theme that he uses, which has several options in the wp_options table.

    What he would like to do is install the theme on sites with some of these options already set so he doesn't have to keep entering the same data over and over. For example 'theme_contact_email' would always default to 'bob@somewhere.com'

    I'm sure there is a simple solution - I just don't know what to search for to find the answer I need. I thought it might be adding set_option somewhere in the template set-up function? I don't see any of the options being created there though so I'm stumped.

  2. colorvila
    Member
    Posted 1 year ago #

    to check if the theme is the first time activated:

    if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
      // load your default data
    }

    Load the default data when your first activate your theme.

Topic Closed

This topic has been closed to new replies.

About this Topic