ButlerBlog

chad butler's weblog

  • About
  • Blog
  • WordPress Plugins
  • Contact

Howto: Write a simple keyword meta tag plugin for WordPress

By Chad Butler 3 Comments

There are various SEO plugins available for WordPress, but let’s say you have some unique needs or for some other reason want to write your own.  How would you go about doing that?

Well, this tutorial is going to show you how to write a very simple plugin to place a basic keyword meta tag in the head of specific posts in WordPress.  (Note: this is not an advanced course in SEO plugin development.  The purpose here is to give you some foundational information that can be applied to more advance projects.)

We are going to do the process in a simple function.

function my_very_simple_meta()
{
   ... some code here ...
}

Keywords will be stored in a custom field for the post so we will need to know the post ID.  The my_very_simple_meta function will be run outside the Loop, so we will need to find the ID using a method other than the_ID(); .

We will declare the $post global and use $post->ID to return the post’s id.

function my_very_simple_meta()
{
  global $post;
 $postID = $post->ID;
}

As I said, we are going to store the keywords in a custom field for the post.  To retrieve that, we use the WP function get_post_custom_values.  This function needs to know the custom field name and the post id (which we retrieved above). (For more information, see the WordPress Function Reference.)

get_post_custom_values($key, $post_id);

This function returns a value as an array, so we will store it in $arr.

$arr = get_post_custom_values('simple-meta', $postID);

Since this particular array is only going to have one value, the keywords will be in $arr[0] (the first value).  We can write the meta tag with this:

echo "";

Putting that together we get the array, then echo (print) the [0] value of the array in a meta tag:

$arr = get_post_custom_values('simple-meta', $postID);
echo "";

Now, what if this particular post does not have any keywords assigned to a custom field called “simple-meta”?  We’ll need to check that with a conditional statement:

if(get_post_custom_values('simple-meta', $postID)){
  ...something here if the condition is true...
}

If that statement is true, we will get the array and write the meta tag.  Let’s put it all together in the function:

function my_very_simple_meta()
{
  global $post;
 $postID = $post->ID;

 if(get_post_custom_values('simple-meta', $postID)) {
 $arr = get_post_custom_values('simple-meta', $postID);
    echo "<meta name=\"keywords\" content=\"".$arr[0]."\" />";
  }
}

Great.  That is going to write a keyword meta tag if there is a custom field for the post called “simple-meta”.  And we can do it outside the Loop.  Now how do we get that into the <html><head> of the document?

WordPress has another fantastic action called wp_head().

add_action('wp_head', 'my_very_simple_meta');

This will fire our new function at the end of the head.

Putting it all together now in a finished file:

<?php
/*
Plugin Name: My Very Simple Meta
Plugin URI:  http://butlerblog.com/plugins/my_very_simple_meta
Description: This is a very simple plugin to place custom keyword meta tags in the &lt;head&gt; of a post or page.
Version:     0.1
Author:      Chad Butler
Author URI:  http://butlerblog.com/
*/

function my_very_simple_meta()
{
  global $post;
 $postID = $post->ID;

 if(get_post_custom_values('simple-meta', $postID)) {
 $arr = get_post_custom_values('simple-meta', $postID);
    echo "&lt;meta name=\"keywords\" content=\"".$arr[0]."\" /&gt;";
  }
}

add_action('wp_head', 'my_very_simple_meta');
?>

[View a formatted sample here.]

Exciting!  “But how do I use it,” you ask?  Save your file as something like my-very-simple-meta.php and load this to your plugins folder.  Go to the WP plugin admin and activate it.  (Note: if you copied the example verbatim, you’ll find the plugin as “My Very Simple Meta” in your list of plugins.)

Once activated, you’ll need to add keywords to a post or a page that you are going to use this for.  Create a custom field called simple-meta and put your keywords in the value field.  That’s it.  If you view the source of your page, you should see these keywords in the head as a meta keyword tag.  You are on your way to becoming a super SEO WordPress plugin guru.

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to email a link to a friend (Opens in new window) Email
  • Click to print (Opens in new window) Print
  • More
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Pinterest (Opens in new window) Pinterest

Filed Under: WordPress Tagged With: code

WP-Members™ 2.3.2 Bug Fix – Apostrophe/Quotation marks in dialogs

By Chad Butler 7 Comments

Following the release of WP-Members 2.3.2, there was a bug brought to my attention by an astute user:

If you are using apostrophes in the custom dialog messages via the plugin’s admin panel, there will be slashes put into your content as the plugin neglects to clean up user input with “stripslashes.”  This bug actually effects all releases from 2.2.0 on to 2.3.2.

This has been address in my next release (which will include bug fixes, but will also be a feature release as we add CAPTCHA).  In the meantime, if it effects you, you can make some simple changes to correct it:

Change line 28 of wp-members-dialogs.php from:

<?php echo $wpmem_dialogs[0]; ?>

to:

<?php echo stripslashes($wpmem_dialogs[0]); ?>

Change line 195 of wp-member-admin.php from:

<textarea id="" name="<?php echo " rows="3" cols="50"><?php echo $wpmem_dialogs[$row]; ?></textarea>

to:

<textarea id="" name="<?php echo " rows="3" cols="50"><?php echo stripslashes($wpmem_dialogs[$row]); ?></textarea>

Hope this helps.

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to email a link to a friend (Opens in new window) Email
  • Click to print (Opens in new window) Print
  • More
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Pinterest (Opens in new window) Pinterest

Filed Under: WP-Members Tagged With: plugins, WordPress, WP-Members

Statement regarding the use of the name wp-Member by SmartMediaPro

By Chad Butler Leave a Comment

I recently became aware of a plugin using the name wp-Member.  This has come to my attention in the form of support issues posted in the wordpress.org forum and tagged wp-members (my plugin).  “[Plugin: WP-Members] Broken upon install — support not helpful — don’t buy.”

While that specific post has since been removed at the request of the original poster since it was not in fact referencing my WP-Members plugin, it makes evident a more important issue.  The plugin this user was actually referencing was not mine, but rather a plugin called wp-Member, offered by SmartMediaPro, and this is not the first occurrence of such confusion.

WP-Members vs. wp-Member

To make this as clear as possible, I will use the names specifically as they are marketed.  WP-Members is the plugin developed and released by me.  It is maintained in the official WordPress Plugin Repository.  It is both free and open source.  If a user of the forums on wordpress.org tags their post wp-members it will be tagged to my plugin (and my attention).  In contrast, the wp-Member plugin is a commercial plugin from SmartMediaPro.  It is neither free nor open source.  The issues that have been posted in the wordpress.org forums seem to stem from the fact that they require the installation of ionCube, a tool for encrypting php source code.

It is very clear that these two names amount to what is known in trademark law as “confusing similarity.”  A similar concept is “likelihood of confusion.”  It should be obvious that, since these two products are active in the same marketplace, there is most certainly likelihood of confusion and confusing similarity.

Date of First Use

In order to emphasize that my date of first use of the name WP-Members precedes that of SmartMediaPro’s wp-Member, I have, where possible, referenced third party links for date claims.  I find purchase viagra online this to be more accurate and reliable than the timestamp on an individual blog.

When the original WP-Members plugin was released publicly, there were no other membership-focused plugins for WordPress of which I am aware, let alone any called WP-Members (or wp-Member).  The May 31, 2006 beta release announcement is not only documented on my blog, but also documented by third party archive.org.  The plugin’s page was first bookmarked by a user on bookmarking site delicious.com June 27, 2006 and listed in the WordPress Codex as early as July 13, 2006 as cached at archive.org. WP-Members was approved and added to the the official wordpress.org repository on 12/15/2007 as documented in WordPress’s subversion tracking.

In contrast, SmartMediaPro announced their release of wp-Member v1.1 on wp-member.com on August 27, 2008.  That seems to be the earliest post on the blog.  The domain was registered on July 7, 2008 (they also registered wp-members.com in 2010).  I cannot find a commercial use of the name prior to 2008.

If that is the case, it places my first use of WP-Members a full 2 years prior to their release and my inclusion in the wordpress.org plugin repository 7 months prior to their domain name purchase (the earliest date).

Going Forward

While this confusion does hurt both parties, I am doing what I can to create separation.  Understand that I have absolutely no relationship with SmartMediaPro nor the plugin wp-Member.  Additionally, based what I have outlined above, I do not believe that SmartMediaPro has a legitimate claim to the name WP-Members.

Although a commercial, pro version is in development, The Original WP-Members will remain a free product and will continue to be open source.  If the WP-Members that you are using was not free and is not open source, it’s not the original and official version.

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to email a link to a friend (Opens in new window) Email
  • Click to print (Opens in new window) Print
  • More
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Pinterest (Opens in new window) Pinterest

Filed Under: WP-Members Tagged With: plugins, WordPress, WP-Members

  • « Previous Page
  • 1
  • …
  • 49
  • 50
  • 51
  • 52
  • 53
  • …
  • 109
  • Next Page »

Join Us!

I will never share your information. No spam. No junk. No kidding. Unsubscribe anytime.

Recent Posts:

  • The High Price of Free Plugins
  • YouTube Success: Key Tips for Enhancing Video Optimization and Visibility
  • Mobile App vs. Mobile Website Ideal Choice for your Business
  • Top Strategies to Boost Your Brand’s Visibility and Impact
  • Advanced Blogging Strategies: Using Analytics, A/B Testing, and Conversion Optimization Techniques to Grow Your Audience
  • Unlock Real-Time Process Insights to Save Time and Money
  • How Writers Can Attract More Audience Attention
  • Dress for Success – Even at Home
  • Mastering the Art of Crafting SMART Marketing Goals
  • Rediscover Your Brand Story: 7 Tips for Refreshing Your Company Identity

Archives

  • About
  • Blog
  • Archive
  • Contact

Site powered by WordPress, running on the Genesis Framework from StudioPress.

Unless otherwise noted, content on this site is © 2006-2025 ButlerBlog and may not be reproduced without express written permission from the author.

Some content may include affiliate links for which this site receives a small commission.