小编Ian*_*Ian的帖子

'使用Wordpress不能使用stdClass类型的对象作为数组'

我正在尝试在wordpress帖子中检索标签的slug,现在可以使用获取所有标签信息

$tag = wp_get_post_tags($post->ID);
Run Code Online (Sandbox Code Playgroud)

关于Wordpress Docs的更多信息

通过使用这个你应该得到这样的数据...

Array
(
   [0] => stdClass Object
       (
           [term_id] => 4
           [name] => tag2
           [slug] => tag2
           [term_group] => 0
           [term_taxonomy_id] => 4
           [taxonomy] => post_tag
           [description] => 
           [parent] => 0
           [count] => 7
       )

   [1] => stdClass Object
       (
           [term_id] => 7
           [name] => tag5
           [slug] => tag5
           [term_group] => 0
           [term_taxonomy_id] => 7
           [taxonomy] => post_tag
           [description] => 
           [parent] => 0
           [count] => 6
       )

)
Run Code Online (Sandbox Code Playgroud)

现在我想要的是第一个项目的slug应该如下

$tag[0]['slug']
Run Code Online (Sandbox Code Playgroud)

但是通过这样做我收到这个PHP错误:

不能使用stdClass类型的对象作为数组 …

php arrays tags wordpress

25
推荐指数
1
解决办法
4万
查看次数

用jQuery改变不透明度

我在网格上有9个项目,我希望所有项目在每个项目上都有0.5个不透明度,并且只有在盘旋时,div/item和内部的所有内容都有1.0 opacicty.

这是JS

$('.gallery-single').css({ opacity: 0.5 });

$('.gallery-single a').mouseover(function(){
    $('.gallery-single-title', this).css('display', 'block');
        $('.gallery-single', this).css({ opacity: 1 });
});
$('.gallery-single a').mouseout(function(){
    $('.gallery-single-title', this).css('display', 'none');
        $('.gallery-single', this).css({ opacity: 0.5 });
}); 
Run Code Online (Sandbox Code Playgroud)

HTML

<div class="gallery-single">
<a href="#" title="">
<div class="gallery-single-title hide">Some text goes here</div>
<div class="gallery-single-img"><img src="http://img.youtube.com/vi/code/0.jpg" width="300" height="200" /></div>
</a>
</div>
Run Code Online (Sandbox Code Playgroud)

加载时所有项目的不透明度均为0.5,但聚焦时不会更改不透明度.我在这做错了什么?

css jquery mouseover opacity mouseout

5
推荐指数
2
解决办法
3万
查看次数

jQuery.timeago插件的时区问题

我正在为我的博客使用timeago jQuery插件,但是时间本身似乎存在问题,我无法指出问题的原因是什么.

它目前在2011年5月31日当地时间2011年02:30(GMT + DST).现在我使用的示例日期是... 2011年5月31日02:01.以下标签为

<abbr class="timeago" title="2011-05-31T02:01:44+00:00">May 31st, 2011</abbr>
Run Code Online (Sandbox Code Playgroud)

然而jQuery输出的日期是"从现在起32分钟",由于某种原因提前一小时.

谁知道我在做错了什么?

jquery timestamp timeago

4
推荐指数
1
解决办法
4937
查看次数

标签 统计

jquery ×2

arrays ×1

css ×1

mouseout ×1

mouseover ×1

opacity ×1

php ×1

tags ×1

timeago ×1

timestamp ×1

wordpress ×1