Add a Favorite Button to Any WordPress Post Type

by on April 5, 2015

favorite

Twitter users have often asked the question: “What does it mean to favorite a tweet?” The act of favoriting can communicate any number of things depending on the context, such as bookmarking, agreeing, showing support, or responding to a mention.

UK researchers studying the favoriting feature on Twitter discovered that users could identify more than 25 distinct motivations for favoriting a tweet. Their qualitative analysis, titled More than Liking and Bookmarking? Towards Understanding Twitter Favouriting Behaviour, dissects the various motivations for using the feature:

The survey responses from these users demonstrate that motives for favouriting tweets are extremely heterogeneous and not always consistent within and between users.

Although many other apps and websites have offered favoriting for years, this study on Twitter favoriting was one of the first to reveal just how complex and nuanced the feature can become in the hands of users.

Add Favorites to WordPress Posts

Favoriting is a subjective activity that is interpreted purely by individual motivation. The simple act of pushing a button results in a myriad of functional and communicative uses, making it one of the more interesting interactive features that you can add to your WordPress site.

Favoriting capabilities are especially important when it comes to custom post types. Not every site needs this feature, but it is particularly helpful for those with large amounts of content stored in custom post types, such as books, recipes, movies, jobs, or real estate listings.

Favorites is a new plugin that was released last month on WordPress.org. It is easy for end users to set up but was also created with developers in mind. The plugin provides an API for adding a favorite button to any post type.

The Favorites settings panel allows you to select the post types where you want favoriting functionality to apply. You can also customize the button text in order to make it suitable for bookmarking, liking, favoriting, or any other similar use.

Favorites will automatically add a favorite button at the top or bottom of your posts. The button intuitively takes on the styles of your active theme, as you can see in this example with the Hew theme:

favorite-button-on-post

Use of the plugin requires WordPress version 3.8+ and PHP version 5.3.2+. Kyle Phillips, author of Favorites, summarized the features to include the following:

  • Use with Any Post Type – Enable or disable favorite functionality per post type while automatically adding a favorite button before and/or after the content. Alternatively, you can use the included functions to display the button anywhere in your template.
  • Available for All Users – Don’t want to hide functionality behind a login? Favorites includes an option to save anonymous users’ favorites by either Session or Cookie. Logged-In users’ favorites are also saved as user meta.
  • Designed for Developers – Favorites works great out of the box for beginners, but a full set of template functions unlocks just about any sort of custom functionality developers may need. Favorites outputs the minimum amount of markup needed, putting the style and control in your hands.

Phillip set up the favoriteposts.com site to house documentation for the plugin, including options, settings, available shortcodes, and a function reference for outputting the button, favorite counts, and a list of user favorites.

screenshot-3

If you’re wondering if Favorites is compatible with your caching solution, the short answer is ‘yes,’ according to the plugin’s FAQ page:

Yes, although the buttons may display the incorrect state momentarily. Button states are updated via an AJAX call after page load in order to accommodate cached pages. This may be noticeable on slower servers.

After having tried many different post bookmarking plugins for WordPress, I found Favorites to be the easiest one to use with the most intuitive button display. If you want to test the plugin without installing it, try out a live demo on favoriteposts.com. Favorites is GPL-licensed and available for free on WordPress.org.

Source: WP Tavern

Add a Favorite Button to Any WordPress Post Type

Related Posts

Take a look at these posts