I am creating a custom table to display selected options for a page called "Testimonials". The user will enter their options on a "manage testimonial settings" page, and then those options will display in a Wordpress-style table on a separate page.

All the settings are stored in an options array called "testimonials_settings" which is shown below:

if(isset($_POST['testimonials_update_options'])) {
   $options = get_option('testimonials_settings'); 
   $options['testimonials_active'] = $_POST['testimonials_active'];
   $options['testimonials_name'] = $_POST['testimonials_name'];
   $options['testimonials_website_name'] = $_POST['testimonials_website_name'];
   $options['testimonials_website_url'] = $_POST['testimonials_website_url'];
   $options['testimonials_quote'] = $_POST['testimonials_quote'];
update_option('testimonials_settings', $options);

In the image below, you can see that I can successfully show these options on a menu page called "Testimonials".

enter image description here Now I'm running into a roadblock because I need to take these settings and display them dynamically in a table for the user to edit/delete/update. So here are my questions:

  1. Can I create code that will display these options dynamically in my current table, considering that I've created the table from scratch?

  2. If so, what would be the process of displaying these options in my table (i.e. could an example be provided to do this?)

  • Your question is confusing, are you referring to a custom database table or just a html <table> output? – Wyck Dec 16 '12 at 23:52
  • Yes, I'm sorry the question is confusing. I'm wanting to retrieve an array of info from the database and display each array in the format shown in my screenshot. But I want to do this dynamically so that each piece of info has an ID and can be added/removed from the table. – Rob Myrick Dec 16 '12 at 23:57
  • Have you had a look at the Settings API? codex.wordpress.org/Settings_API – Wyck Dec 17 '12 at 0:14
  • this would be infinitely easier with a custom post type, this is exactly the use case they exist for. the save/edit/delete UI is already there, just add your custom type and you are essentially done. options are not intended as content storage, it is a simple key/value storage for simple plugin and theme options. – Milo Dec 18 '12 at 16:20

Your Answer

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

Browse other questions tagged or ask your own question.