WordPress调用指定友情链接分类目录下的链接名

Author: 陌小雨Date: 2016-08-04View: 204

Wpdyljfl

WordPress调用指定链接分类目录下的链接名,首先要知道如何访问数组中的stdClass Object?使用print_r($data)输出结果为:

Array
(
    [0] => stdClass Object
        (
            [color_item_no] => 1
            [color_name] => sdf
            [size_item_no] => 1
            [size] => S
            [jar_no] => 45
            [qty] => 45
            [stand_wgt] => 
            [qty_unit] => 1
        )

    [1] => stdClass Object
        (
            [color_item_no] => 1
            [color_name] => sdf
            [size_item_no] => 2
            [size] => M
            [jar_no] => 45
            [qty] => 45
            [stand_wgt] => 
            [qty_unit] => 1
        )

    [2] => stdClass Object
        (
            [color_item_no] => 1
            [color_name] => sdf
            [size_item_no] => 3
            [size] => L
            [jar_no] => 45
            [qty] => 4
            [stand_wgt] => 
            [qty_unit] => 1
        )

)

我使用echo $data[0]['size']提示错误,不然该怎么访问呢?

其实正确的调用方法应该为:$data[0]->size

举上面这个例子,其实是因为陌小雨最近替客户调用WordPress指定链接目录下链接名的时候,需要用这个方法来调用:

代码示例:

 <?php $bookmarks = get_bookmarks('title_li=&orderby=id&categorize=0&category=4'); 
 echo $bookmarks[0]->link_name;
>