• Hi, this is a code it displays custom taxonomies and its values in a table.It works very fine for me.
    Now i want to modify it to display custom fields keys and its values.Kindly help me.

    This is code:

    function mil(){
      // get post by post id
      $post = get_post( $post->ID );
    
      // get post type by post
      $post_type = $post->post_type;
    
      // get post type taxonomies
      $taxonomies= array(
                             "category"=>"Categories: ",
                             "post_tag"=>"Tags: ",
    						 "os"=>"OS: ",
                             "platform"=>"Platform: ",
    						 "developer"=>"Develepor: ",
                             "publisher"=>"Publisher: "
                      );
    
      $out = array();
      $out[] = "<table width='100%' border='0' cellspacing='0' cellpadding='0' class='pc-meta'> <tr>
        <td colspan='2'><h2>". $post_type." Information";"</h2></td>
      </tr>";
      foreach ( $taxonomies as $tax => $taxname ){
        // get the terms related to post
        $terms = get_the_terms( $post->ID, $tax);
    
        if ( !empty( $terms ) ) {
    
          $out[] = " <tr><td valign='middle'>" . $taxname ."</td>\n<td valign='middle'><ul>";
    
          foreach ( $terms as $term ) {
            $out[] =
              '  <li><a href="'
            .    get_term_link( $term->slug, $tax ) .'">'
            .    $term->name
            . "</a></li>\n";
          }
          $out[] = "</td></tr>\n";
    
        }
      }$out[] = "</table>";
      return implode('', $out );
    }

  • The topic ‘How To Display Custom Fields Keys and Values’ is closed to new replies.