I am struggling to save the correct data in my themes options page. Here is my code in my functions.php file:

if ( get_option( 'everes_options' ) ) { 
    $everes_options = get_option( 'everes_options' ); }
else {
    add_option( 'everes_options', array(
        'everes_pdf' => '1', 
        'everes_showBlog' => '1'
    ) );
    $everes_options = get_option( 'everes_options' ); }

function everes_options(){
    global $everes_options;
    <div class="wrap">
      <h2>Resume Options</h2>
      <form action="edit.php?post_type=employment&page=resume_options" method="post">
            <td>Print as PDF?</td>
              <select name="everes_pdf">
                <option value="1" <?php selected( '1', $everes_options['everes_pdf'] ); ?> >Yes</option>
                <option value="0" <?php selected( '0', $everes_options['everes_pdf'] ); ?> >No</option>
            <td>Show blog</td>
              <select name="everes_showBlog">
                <option value="1" <?php selected( '1', $everes_options['everes_showBlog'] ); ?> >Yes</option>
                <option value="0" <?php selected( '0', $everes_options['everes_showBlog'] ); ?> >No</option>
            <td colspan="2"><?php submit_button(); ?></td>
<?php } ?>

When I submit the data, it will save the data, but after a few clicks in the menu, or refreshed in the website, the data disappears. I can't see where the issue is, but I do believe that it would be glaringly obvious to someone here. Any help? Please?

  • 1
    Your code is quite bad, why the action of the options form is edit.php? Anyway, you should use the Settings API to build a theme or plugin options page. – cybmeta Sep 7 '14 at 17:31
  • It might be duplicating things, but this is for a resume theme. I have a set of options specifically for the resume and one specifically for the theme. I guess, since they are both small, I should really combine them. – Nate Sep 7 '14 at 17:37
  • However, I have followed a video tutorial for this, which can be found here: youtube.com/watch?v=ZAkdS3qMCzs (Apologies if this violates any rules, I did get into trouble for posting an external link before). I've probably royally screwed it up, but that's what I do best. – Nate Sep 7 '14 at 17:40

I have found the solution that I was (sort of) looking for. I searched for a video tutorial to integrate my settings with the Theme Customization page, which does pretty much what I wanted it to, and I think might actually be more beneficial there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.