0

我希望能够在论坛帖子上方显示 Super Sticky 或 Sticky 帖子。换句话说。我将在页面上发布帖子,并且超级/粘性帖子将在那里。但是,在帖子列表的上方,我也希望在那里有超级/粘性帖子。有点像“特色讨论”类型的部分。

4

2 回答 2

1

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

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)

        })

希望这对其他人有帮助。

于 2012-08-14T22:40:55.133 回答
0

这是一个更简单的答案,来自这个 bbpress.org 线程

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

于 2018-11-12T19:32:40.173 回答