NextGEN Excerpts

Posted in PHP, Wordpress on November 1st, 2011 by jonolan

Wordpress W/ Wrench - Tech and Tool Tips for WordPress.org sitesWordPress is a great blogging platform and overall CMS. Part of its utility comes from its in-built capability to display excerpts from posts and pages, which makes displaying search results and archives much more elegant.

This is, however, not without its flaws. One the most common problem with excerpts is WordPress that WordPress shortcodes don’t work in excerpts.

When one of the most commonly utilized plugins for WordPress is Alex Rabe’s NextGEN Gallery plugin, which heavily relies upon shortcodes, this is a problem.

Fortunately, WordPress’ Shortcode API has within it the capability of easily and quickly fixing this issue.

Below is the default PHP statement to display a post’s excerpt in WordPress:

< ? php the_excerpt(); ?>

The problem with the_excerpt() function is that it echoes the excerpt directly to the screen without interpretation. This causes the shortcode itself to display in the excerpt rather than the code it was calling.

In order to have NextGen Gallery entries appear in the post excerpts, simply replace that line wherever it occurs in your blog’s theme files with the following:

< ? php echo do_shortcode(get_the_excerpt()); ?>

The do_shortcode() function actually runs the shortcodes and returns their results as a string. Hence, it will allow your NextGEN Galleries – and anything other shortcodes – to display properly within post excerpts.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon] [Twitter]

Deleting Post Revisions

Posted in SQL, Wordpress on April 10th, 2011 by jonolan

WordPress W/ Wrench - Tech and Tool Tips for WordPress.org sitesWhenever you create or edit an article in WordPress, the software suit will save multiple revision copies of the article. This is a waste of server and database resources. Excessive or extraneous revision records will increase the burden on the underlying database.

This will increase loop iterations, data retrieval, and page loading time.

Periodic deletion of these post revision and all their associated metadata should be considered part of your normal maintenance routine. This can be accomplished with a simple SQL statement:

DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'

NOTE: Depending on exactly how WordPress was installed, the table names (wp_posts, wp_term_relationships, & wp_postmeta) may need to be modified to include the blog name, e.g., wp_yourblogposts.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon] [Twitter]

OG: Social Plugins

Posted in Coding & Scripting, Social Media, Tech Buzz on May 15th, 2010 by jonolan

Facebook's Open Graph ProtocolRecently Facebook released a platform, the Open Graph Protocol, which allows websites and applications to share information about users in order to tailor offers, features and services to each one’s interests and tastes.

It enables any web page to become an object in a social graph that can plot users’ activities and to function much as if it was a Facebook page.

The Facebook Developers’ first integration features are called Social Plugins. This is currently a set of eight (8) plugins which can easily be added to any web page or application in order to connect it more closely to Facebook, offer a set of  features from Facebook, and take advantage of the Semantic Web that Facebook is developing.

  • Like Button:
    Show a “Like” button on your site which replaces the older “Fan” button. The is currently most commonly used Social Plugin.
  • Recommendations:
    Show users personalized suggestions for pages on your site they might like based upon their history as recorded via the Open Graph Protocol and API.
  • Login with Faces:
    Allow the users to sign up to your site with their Facebook account. it also shows a list of the user’s friends who have also signed up for your site.
  • Comments:
    Allow users to comment on your site. The comments will also be posted back to the users Facebook wall.
  • Activity Feed:
    shows users what their friends are doing on your site through likes and comments.
  • Like Box:
    This is previously known as the Fan box.
  • Facepile:
    Shows profile pictures of the user’s friends who have already signed up for your site.
  • Live Stream:
    Lets your users share activity and comments in real-time as they interact during a live event.

These social plugins allow website developers to create websites that have all or most of the social media functions of Facebook pages. In theory this would not only drive more traffic to Open Graph enabled websites, but also reduce the “bounce rate” by enabling greater interaction with the sites in question.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon] [Twitter]