WordPress.org

Ready to get started?Download WordPress

Forums

125

Adhesive: A new sticky WP plugin (150 posts)

  1. ringmaster
    Member
    Posted 9 years ago #

    This thing was kind of a proof of concept for something else I was doing, but it seems to work well enough to release.
    Adhesive is a WordPress plugin that lets you easily mark posts as sticky. Adhesive is different than other plugins I've found with similar functionality for two reasons:

    1. You don't need to modify any WordPress code.
    2. You need only check a box when you want to make something sticky.

    Other stuff that you might want to know: Adhesive uses post meta fields to store its sticky status. Sticky posts only appear in the categories that they've been assigned to. If you've modified your index.php heavily (fetching the $posts array in a different way than the default), then this plugin may not work for you. Adhesive should maintain the posts_per_page setting in your options - I'm not sure whether other sticky plugins do this.
    The upside is that if if doesn't do what you want, you can just deactivate it and delete it. :)
    To install Adhesive, drop the file in your plugins directory and activate it on the Plugins tab. That's it!
    Enjoy.

  2. TechGnome
    Moderator
    Posted 9 years ago #

    quothe ringmaster"Adhesive should maintain the posts_per_page setting in your options"
    Hmm... so does that mean if I have mine set to 5, and I have 3 stickies in a category, then I get the 3 stickies, plus two more, for a total of 5? Or do I get the stickies plus the 5, for a total of 8?
    TG

  3. Icyshard
    Member
    Posted 9 years ago #

    This plugin is very cool--and easy! I love that it gives you a checkbox option--and NO messing with the core code! However, when I tested it out on my page, which lists the last 5 posts on the index page, it didn't keep 5 entries. The sticky entry moved to the top, but then there were only 4 entries on the page.
    I noticed that this only happened when I made one of the last 5 posts on my page sticky--like it was counting the entry twice--once as being the sticky post, and once as being one of the regular posts on the page. When I made a very old entry sticky, there were 5 entries on the index page--I guess because it wasn't a part of the regular $posts array?
    Not a huge deal, but if it's easily fixable, that would be great!

  4. Cypher
    Member
    Posted 9 years ago #

    I also tried this plugin and it works quite nice. It would, however, be nice to have a feature where sticky'ed posts would stick out somehow from regular posts to show their importance.
    I suppose I could make the posting itself BOLD, but it would be nice if there was some image or font change or something. Just a thought.

  5. ringmaster
    Member
    Posted 9 years ago #

    I've made changes to accomodate these two issues.
    The new code can produce two CSS classes on a sticky post. One goes around the just body of the post and requires no index.php modification; each sticky post's content is wrapped in a div with the new class. The other one goes around the the entire post including the title and requires a minor index.php modification to the style of the main post div. In either case, you will not need a second WP loop to display styled stickies.
    I've also written code to fix the bump issue that Icyshard talks about. It was in fact deleting the sticky post (one of the last few) from the $posts array and popping an old post off the bottom. It shouldn't do this any more.
    Hopefully, I'll have this all tested and online early tomorrow. Any other issues?

  6. ringmaster
    Member
    Posted 9 years ago #

    The new version is online with some changes from my post of last night.
    Only one new class is added, and it's added at the full post level (the div that surrounds the title and the content). It is added via script, so no changes are required to the index.php to use it.
    Just add a style ".adhesive_post" to your CSS file, and you should be able to alter it.
    Download the new version here.

  7. Anonymous
    Unregistered
    Posted 9 years ago #

    my server uses an older mysql version, so create temporary table doesn't work. any solution to this?

  8. ringmaster
    Member
    Posted 9 years ago #

    Uh... Upgrade? :)
    The only other solution I can think of uses subqueries, and using subqueries in MySQL is a newer feature than temporary tables.

  9. stduval
    Member
    Posted 9 years ago #

    Any chance you can remove the date on the sticky post??

  10. ringmaster
    Member
    Posted 9 years ago #

    Get the new version (1.2) if you don't want to display dates on sticky posts.

  11. wairoanz
    Member
    Posted 9 years ago #

    Hi Ringmaster. When I try to download from your page it requests a password. Please let me know how I might gain access, thanks.

  12. ringmaster
    Member
    Posted 9 years ago #

    @wairoanz:
    1) I don't see what you see. Look here. The topmost post ("Exhibit Photo Test") was posted on June 7 and is sticky. You see there is no date shown for the post. You should also see that all of the other posts have dates like they're supposed to. (If more than one post is on the same day, it doesn't redisplay the date.) So if you could explain/show me what you mean, maybe I can help?
    2) Ok. On line 262 of adhesive.php, change the empty string (return '';) to your message (return 'READ ME NOW!';). That text will display instead of the date.
    I'm not inclined to get too fancy with this plugin, since the 1.3 release of WordPress has a few more hooks in it that should make this sort of thing easier to accomplish in a more efficient way. When 1.3 is released (or before), I'm sure there will be about 30 plugins that all do the same thing as this one.

  13. wairoanz
    Member
    Posted 9 years ago #

    Ringmaster, see: http://www.wairoa.com/
    As above I changed line 262 to:
    return '<h2>Featured Article</h2>';
    So now that is showing up fine on the Sticky Articles, however, there are no dates showing on the following articles (on the home page).
    Also, I have commented out this line as follows:
    // add_filter('the_date', 'adhesive_the_date', 15);
    But, the result is the same with it in or out (since changing line 262 mentioned above).
    So I'm puzzled. Any clues?

  14. wairoanz
    Member
    Posted 9 years ago #

    UPDATE: Ah! I set the wordpress option to include more articles, and so what I see now is that the date will show on days that articles are not marked as sticky. If several articles appear from the same date, and one is marked sticky, then (if dates are turned off, or line 262 is chaneged) then dates will not show for all posts that day. Jeepers... hope you understand... I'm getting myself confused just trying to explain it. :)

  15. wairoanz
    Member
    Posted 9 years ago #

    OK, well I couldn't leave it up like that for too long, but I figured out how to use it in a way that will still work for me most of the time, i.e. as long as the sticky item is from a date outside the range of dates appearing on the homepage, it looks OK.

  16. wairoanz
    Member
    Posted 9 years ago #

    Furthermore: Something else for you to consider Ringmaster... if I move an article from published to draft and then come in via the old link (i.e. perhaps listed in Google for example), the following errors show up:

    Warning: array_filter() expects argument 1 to be an array in /home/httpd/vhosts/wairoa.com/httpdocs/wp-content/plugins/adhesive.php on line 173
    Warning: The argument needs to be an array in /home/httpd/vhosts/wairoa.com/httpdocs/wp-content/plugins/adhesive.php on line 186
    Warning: First argument to array_unshift() needs to be an array in /home/httpd/vhosts/wairoa.com/httpdocs/wp-content/plugins/adhesive.php on line 192

    See, for example: http://www.wairoa.com/2004/07/18/coastal-forecast-gale-warnings-in-force/
    Please note that that article was not ever used as a sticky item.

  17. ringmaster
    Member
    Posted 9 years ago #

    Yikes. Confusing. :)
    Actually, I think I see what's going on. To summarize: If the sticky post was posted on the same day as the post that would immediately follow it on the home page, then the post that immediately follows it (and any other posts that day) would not have a date shown.
    Also, if a post is somehow unavailable for public viewing (such as a draft or a non-existant post) then it generates an error in Adhesive.
    Both of these I can fix...

  18. wairoanz
    Member
    Posted 9 years ago #

    Yes, you have summarized it perfectly. :)

  19. wairoanz
    Member
    Posted 9 years ago #

    Ringmaster, any update on when you may be able to fix the 2 points summarized above? Thanks in advance.

  20. ringmaster
    Member
    Posted 9 years ago #

    1.3 is available. It includes a fix so that when you display posts by date there are no stickies. It includes a fix for displaying the date of posts that are on the same date as the sticky (see above). It no longer causes an error if there are no posts to diplay.

  21. gravity
    Member
    Posted 9 years ago #

    Just so you can see what 1.3 does -
    http://www.gravityworks.us/a.wpblog/
    Kind regards,
    Gravity

  22. gravity
    Member
    Posted 9 years ago #

    all I did was change from 1.2 to 1.3 and that is what happened.. did not get them in 1.2....
    I am sure Ringmaster is working on it.. just waiting on a response from him here..

  23. duches77
    Member
    Posted 9 years ago #

    wairoanz - I like how you put the exclaimation point in your sticky. Nice touch there. How'd you do that?

  24. gravity
    Member
    Posted 9 years ago #

    Let me redownload it.. and see what happens.. maybe I gots a bad one..
    Nope.,. I deactivated 1.3 and then downloaded a new one.. then deleted the old one.. then reactivated.. then chose a new post to be the sticky and wala..
    same deal..

  25. wairoanz
    Member
    Posted 9 years ago #

    I have reverted back to adhesive 1.2 due to problem mention in my post #27.
    @duches77
    I added the exclamation through css, as follows:
    .adhesive_post {
    background: rgb(255, 255, 255) url('wp-images/exclamation.gif') no-repeat scroll right top;
    margin-top: 0px;
    margin-right: 20px;
    margin-left: 22px;
    margin-bottom: 6px;
    border: 1px dotted #ccc;
    padding: .7em;
    }

  26. duches77
    Member
    Posted 9 years ago #

    Thanks, wairoanz...
    gravity - 1.2 seems to work fine on wairoanz site, but there was a lot of additional work on it. Perhaps you can try reverting to 1.2 and duplicate some of the steps wairoanz took here...?

  27. gravity
    Member
    Posted 9 years ago #

    The problem in version 1.2 is that the date is missing on the sticky post.. It is also missing when you click on the archives. However, it is there if you choose the day of the sticky from the calendar.
    So it is something with version 1.2.....
    and 1.3 is just bonk.
    http://www.gravityworks.us/a.wpblog/index.php?cat=all

  28. ringmaster
    Member
    Posted 9 years ago #

    Be sure to check out the other thread.
    http://wordpress.org/support/10/9348

  29. gravity
    Member
    Posted 9 years ago #

    Hello RingMaster,
    I just downloaded 1.3 for adhesive.. and I made the change I made in 1.2 for style="clear:both;"
    However, this time it is not working. I have temporarily changed back to 1.2 with style="clear:both;" which is working. You can see that here..
    1.3 just gives me the index page again, even with the change.
    http://www.gravityworks.us/a.wpblog/index.php?static=contact
    Kind regards,
    Gravity

  30. ringmaster
    Member
    Posted 9 years ago #

    @gravity:
    What you're saying isn't making sense to me. Are you talking about EzStatic? You're in the wrong thread.

125

Topic Closed

This topic has been closed to new replies.

About this Topic