You have a blog running WordPress. You like to use the ‘more’ link for post excerpts, but you have ads running at the top of the page and the ‘more’ link puts in an anchor by default that takes the user lower on the page. How can you remove the anchor so the user goes right to the top of the page? [Read more…]
Write a simple WP plugin to add the trademark symbol (™) to your mark
You have a trademark you need to mark on your WordPress site, but you don’t want to search through the site to find each occurrence and update each post? I have developed a plugin for you that will ™ or ® your content on the fly. But if you are the do-it-yourselfer type, then here’s a way to make a simple plugin to filter every instance of your trademark in posts, pages, and titles.
It is assumed that the reader has a basic working knowledge of PHP as I am not going to go into explaining the particulars of the PHP constructs. While you could just copy and paste, it will be easier if you know the basics.
Filter the Content
The first function will go through the_content
and replace every instance of your trademark with your trademark(tm). We will call this tm_the_content. WP stores the content of a post or a page in the variable $content
, which we will pass to the function.
function tm_the_content( $content ) { ... we'll add code here later ... }
We will use str_replace to find the instances of Our-Trademark (replacing “Our-Trademark” with the actual trademark text you are working with) in $content and replaced it with Our-Trademark(tm). Note, I am using ™
for the trademark symbol, but you could put in place <sup>
superscript or <div>
and CSS, or what suits your fancy. I like keeping it simple, though. (Note: you can also replace ™ with ® to get the registered trademark symbol (r) ).
$content = str_replace("Our-Trademark", "Our-Trademark™", $content);
Now $content has all instances of Our-Trademark replaced with our trademark(tm), but we need to send back the filtered content:
return $content;
Functions and Filters:
function tm_the_content($content) { $content = str_replace("Our-Trademark", "Our-Trademark™", $content); return $content; }
WordPress stores the title of a post or a page in the variable $title
. Filtering $title is exactly the same as filtering $content
, so we can build our function tm_the_title
by essentially copying tm_the_content
and changing $content
to $title
:
function tm_the_title($title) { $title = str_replace("Our-Trademark", "Our-Trademark™", $title); return $title; }
And you thought this was going to be hard. 😉
Now we need to fire these functions at the appropriate time. As I mentioned earlier, in WordPress, we do this by using add_filter
.
In case you were unaware, WordPress has a built-in function called add_filter() that will fire a function to filter your content. We will use two instances of add_filter() to filter both the_content, the function that gets the $content of a post or a page, and the_title, the function that gets, you guessed it, the $title.
When you use add_filter()
, you need to send the function two things, what you are filtering, and the function to use to do the filtering:
add_filter( $tag, $function_to_add, $priority, $accepted_args );
The last two parameters are optional, and in this case, we will only be using the first two. We will use this twice in our plugin to fire each of our functions:
add_filter('the_content', 'tm_the_content'); add_filter('the_title', 'tm_the_title');
Put it all together:
<?php add_filter('the_content', 'tm_the_content'); function tm_the_content($content) { $content = str_replace("Our-Trademark", "Our-Trademark™", $content); return $content; } add_filter('the_title', 'tm_the_title'); function tm_the_title($title) { $title = str_replace("Our-Trademark", "Our-Trademark™", $title); return $title; } ?>
Here is a sample of the code.
Well that’s it. I hope that you will find this snippet of code useful.
5 social networking sites you haven’t heard of but should be using
When I started blogging, most people didn’t even know what a blog was. There was a kind of pioneer spirit; of breaking new ground. As blogging came into its own and the mainstream media began to buzz about it, blogging became a household word. Soon it seemed as if everyone either had a blog, was starting a blog, or at the very least, was reading several blogs. Those that started early found it easier to rise to the top; they had the new thing and the momentum when the trend came.
Then there was social media. Sites like Facebook, Twitter, and Digg became great places to promote your newly started blog or to find other blogs and bloggers. Now it seems as if everyone is using these sites to promote their blogs. It can be a difficult task to rise to the top with the well known sites. You have to put in some tremendous work upfront to see results. Not that you shouldn’t utilize these sites, you definitely should. But you also need to consider other avenues that, while not as popular now, could be in the future. These sites can help you build traffic and momentum to get your blog noticed.
Squidoo allows you to write pages called “lenses” on squidoo.com. You can publish these pages free.
Lenses are pages, kind of like flyers or signposts or overview articles, that gather everything you know about your topic of interest–and snap it all into focus. Like the lens of a camera, your perspective on something. (You’re looking at a lens right now).
Using Squidoo gives you exposure as an expert on a given topic. But not only can you get exposure (and possibly traffic to your blog), but you can earn money as well. Squidoo gives you a share of the ad revenue generated by your lens(es). If you are cool, you can give your revenue to charity.
Much like Squidoo, Hubpages allows you to publish “hubs” in areas you are knowledgeable. Gain exposure as an expert, generate traffic and an audience, earn a revenue split.
Anyone can be a part of the HubPages community, a leading source of answers and expert content on the web, where even new authors can enjoy hundreds or even thousands of readers. Authors can even earn money through online ads displayed on their hubs.
Plurk is a micro-blogging platform like Twitter. But unlike Twitter, Plurk uses a timeline for “plurks” and threads the responses within each plurk. While Plurk is a little behind Twitter in terms of popularity, this shouldn’t be overlooked as an opportunity for social networking.
You may have heard of Reddit, but do you use it? Reddit is similar to Digg and StumbleUpon, providing users an opportunity to rate sites and links either up or down. A great place to find interesting links and participate in community.
Tagfoot combines social bookmarking ala delicious, tagging like Technorati, rating like Digg, and sharing like Stumbleupon. This Squidoo lens describes Tagfoot like this:
I’m not sure if it’s the bastard child of Digg and HubPages or the lovechild of Del.icio.us and Squidoo. But it’s hot, it’s happening and it’s HERE.
A bonus with Tagfoot is that if you use AdSense, you can get 50% of the impressions for your own ads.
- « Previous Page
- 1
- …
- 14
- 15
- 16
- 17
- 18
- …
- 20
- Next Page »