• Hi
    I’ve inherited a WP website and am not very familiar with it…finding my way as I go. I am working with a custom field that was set up by the site designer. I have a field called df-post and the assigned values are of the format nn,nn (eg. 57,11). I know what the second number relates to, it is the service id all our posts are assigned to, but I don’t know what the first number relates to. The number varies from 2 to 4 digits (57-1038) but is the same number for groups of posts. I thought if I could look at the whole list of values somewhere I might be better able to work it out. What I want basically is a list of custom fields and the associated values.
    I saw MichaelH suggest to someone using use phpMyAdmin on wp_postmeta but when I read about this I don’t know if my skills are up to going near the database.
    I tried changing the value to what I want it to be and updating the custom field, but it just resets to 0.
    Does anyone have any suggestions?
    Many thanks
    K

Viewing 1 replies (of 1 total)
  • Copy this code to listcustomfields.php in your theme’s folder. Create a new Page and assign it as the template. View the page.

    <?php
    /*
    Template Name: List Custom Fields
    */
    $spacer = '&nbsp;&nbsp;&nbsp;&nbsp;';
    get_header(); ?>
    <div class='content'>
       <?php
       $sql = "SELECT *,count(meta_key) as count
          FROM $wpdb->postmeta
          WHERE meta_key NOT LIKE '\_%'
          GROUP BY meta_key, meta_value
          ORDER BY meta_key, meta_value";
       $rows = $wpdb->get_results($sql);
       foreach ($rows as $row) {
          if ($row->meta_key != $curr_key) {
             $curr_key = $row->meta_key;
             echo "<h2>$spacer KEY: $curr_key</h2>";
          }
          if ($row->count > 1) {
             echo "$spacer$spacer($row->count times): ";
          } else {
             echo "$spacer$spacer($row->count time): ";
          }
          echo "$spacer $row->meta_value<br />";
       } ?>
    </div>
    <?php get_sidebar();
    get_footer();
    ?>
Viewing 1 replies (of 1 total)

The topic ‘Custom Fields – can I view assigned values’ is closed to new replies.