首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在论坛帖子上方显示bbpress Super Sticky或Sticky帖子?

如何在论坛帖子上方显示bbpress Super Sticky或Sticky帖子?
EN

Stack Overflow用户
提问于 2012-08-14 02:44:28
回答 2查看 720关注 0票数 0

我希望能够显示超级粘性或粘性以上的论坛帖子。换句话说。我会在页面上有帖子,超级/粘性帖子会在那里。然而,在帖子列表之上,我希望超级/粘性帖子也在那里。有点像“特色讨论”类型的部分。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-15 06:40:55

所以我最终这样做是为了解决我的问题。我在表的上方添加了一个包含主题的div,然后执行了一些jquery,如下所示:

代码语言:javascript
复制
var rows = $('table.bbp-topics').find('tr.super-sticky');

        rows.each(function(index) {
            var headhref = $('a.bbp-topic-permalink', this).attr('href');
            var headline = $('a.bbp-topic-permalink', this).html();
            var excerpt = $('.excerpt', this).text();
            var author = $('a.bbp-author-name', this).html();
            var photo = $('a.bbp-author-avatar > img', this).attr('src');
            var replies = $('.bbp-topic-voice-count', this).text();
            var followers = $('.bbp-topic-reply-count', this).text();
            var freshness = $('.bbp-topic-freshness > a', this).html();
            var meta = $('p.bbp-topic-meta', this).text();


            var newrow = '<div class="featured-row"><div class="topic-meta">' +
                '<img class="author-photo" src ="' + photo + '">' +
                '<div class="author">' + author +'</div> ' +
                '<div class="topic-title"><a href="' + headhref + '">' + headline + '<a/></div>' +
                '<div class="excerpt">' + excerpt + '</div></div>' +
                '<div class="replies"><h3>Replies</h3><hr/><p>' + replies + '</p></div> ' +
                '<div class="followers"><h3>Followers</h3><hr/><p>' + followers + '</p></div> ' +
                '<div class="freshness"><h3>Updated</h3><hr/><p>' + freshness + '</p></div> ' +
                ' </div>';

            console.log(newrow);

            $('#supersticky').fadeIn().append(newrow)

        })

希望这对其他人有所帮助。

票数 1
EN

Stack Overflow用户

发布于 2018-11-13 03:32:40

这里有一个更简单的答案,from this bbpress.org thread

$query = new WP_Query(array('post__in' => bbp_get_super_stickies());

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11940386

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档