WordPress.org

Support

Support » Plugins and Hacks » Adhesive: A new sticky WP plugin

Adhesive: A new sticky WP plugin

  • 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.

Viewing 15 replies - 1 through 15 (of 149 total)
  • TechGnome

    @techgnome

    Moderator

    quothe ringmasterAdhesive 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

    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!

    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.

    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?

    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.

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

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

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

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

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

    @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.

    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?

    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. 🙂

    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.

    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.

Viewing 15 replies - 1 through 15 (of 149 total)
  • The topic ‘Adhesive: A new sticky WP plugin’ is closed to new replies.