Can’t display specific content of an array PHP and WordPress

I’m starting to getting along with PHP but I’m still learning, so I need some basic help.

I want to display only the value of the ‘mini-description’ in this array:

Read More
Array ( [0] => Array ( [name] => mini-description [value] => Suspendisse in tempus felis. [position] => 1 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 0 ) ) 

and I’m trying to do this:

$postid = get_the_ID();
$mini = get_post_meta( $postid, '_product_attributes', array( 'mini-description' => 'value' ));
echo $mini;

But the result is: Array

Any solution? Thanks in advance.

Related posts

3 comments

  1. try

    echo  $mini['mini-description']['value'];
    

    or

    echo  $mini['mini-description']->value;
    
  2. If you need value of ‘mini-description’ only, you can use following code:

    $mini = get_post_meta( $postid, 'mini-description', true);
    echo $mini;
    

    You need to test this in your code. Let me know if works.

    In Woocommerce, you can do something like this:

    $terms = get_the_terms( $productId, 'mini-description');
    
    foreach ( $terms as $term) {
          echo $term->value;
    }
    

Comments are closed.