Tagged: 

Viewing 3 reply threads
  • Author
    Posts
    • #6918

      I’m trying to retrieve a field value from a settings page but I haven’t been successful yet. This is what I’m doing:

      <?php
                  $theme_options = get_option('lawyeah_theme_settings');
                  $stmp_postn1_vsb = $theme_options['stmp_postn1_vsb'];
                  echo $stmp_postn1_vsb;
      ?>

      NB: stmp_postn1_vsb is the field name of the field whose value I want to retrieve.

      I’ve also tried to use get_option($stmp)postn1_vsb, $default = show); but in vain.
      I’ve also tried to use this as per the documentation,

      <?php
        $theme_options = get_option('my_theme_settings');
        $stmp_postn1_vsb = $theme_options['$stmp_postn1_vsb']; 
        echo 'Testing this field' . $stmp_postn1_vsb;
       
      ?>

      One thing that has been so noticeable about using the above code is that it throws an error that says,

      <b>Notice</b>:  Array to string conversion in <b>C:\xampp\htdocs\lawyeah\wp-content\themes\Joshua\footer.php</b> on line <b>111</b>
      This is a test fieldArray
    • #6923
      Steve
      Keymaster

      Looks like $stmp_postn1_vsb is an array. To see the value use print_r instead of echo: print_r($stmp_postn1_vsb);

      To use it you will need to loop over the array using foreach.

    • #6930

      Thanks a lot Steve. I followed your advice and it surely did work. I did it like this:

      <?php 
      $theme_options = get_option('libra_settings'); 
      $stmp_area_vsb = $theme_options["stmp_area_vsb"]; 
      foreach ($stmp_area_vsb as $value) { 
      echo "$value";
      }?>
    • #6931
      Steve
      Keymaster

      Perfect!

      Since Piklist does everything the WordPress and PHP way, that code will work on any array. Not just Piklist.

      Closing ticket.

Viewing 3 reply threads
  • The topic ‘How to get data from settings page to show on frontend’ is closed to new replies.