如何获取多维Cookie作为变量?

时间:2018-12-27 05:56:30

标签: php json wordpress cookies

我试图将之前设置的cookie放入json,我用以下方法获取cookie:

$cookie = stripslashes($_COOKIE['cookieBook']);
$cookie_decoded = json_decode($cookie);

和结果:

Array
    (
        [0] => stdClass Object
        (
            [id] => 2
            [title] => Book A
            [url] => https:// Book A URL /
        )
    )

我想获取id作为变量并将其插入显示类别第一篇文章的数组中。

$catid = 'id value from the cookie'; 
$newest = array('posts_per_page' => 1, 
'cat' => $catid
); 
$books = new WP_Query($newest) 

0 个答案:

没有答案