'Cannot use object of type stdClass as array' using Wordpress

前端 未结 2 1778
再見小時候
再見小時候 2020-12-09 02:59

I am trying to retrieve the slug for a tag inside a wordpress post, now its possible to get all tag info using

$tag = wp_get_post_tags($post->ID);
         


        
2条回答
  •  生来不讨喜
    2020-12-09 03:19

    Another option should be to explicitly cast $tag[0] into an array:

    $t = (array)$tag[0];
    $t["slug"] = ...
    

    Can't get it to work though

提交回复
热议问题