Need help with wordpress plugin.

Status
Not open for further replies.

ed146

Still Hustlin'
May 23, 2007
430
2
0
Here is a small problem I am having. I have a plugin that scans the content on my site then turns a specific keyword that I choose into an affiliate link.

However, I would like to only turn keywords into aff links on posts not keywords from "Pages".

If anyone can take a look at the plugin and let me know what I need to modify please shoot me a pm or reply.

Thanks and Merry Christmas!
 


should be a pretty easy conditional tag that you throw into the plugin's source code. if you're in a post, do this, if your in a page, do nothing.
 
Conditional Tags WordPress Codex

A PAGE Page

This section refers to WordPress Pages not any generic webpage from your blog.
is_page()
When any Page is being displayed.

is_page('42')
When Page 42 (ID) is being displayed. is_page('About Me And Joe') When the Page with a post_title of "About Me And Joe" is being displayed. is_page('about-me') When the Page with a post_name (slug) of "about-me" is being displayed.

is_page(array(42,'about-me','About Me And Joe'))
Returns true when the Pages displayed is either post ID 42, or post_name "about-me", or post_title "About Me And Joe". Note: the array ability was added at Version 2.5.
 
Radio took care of it for me.

Thanks for all those who offered to help me.
 
Code:
<?php

/*
Plugin Name: Replace Keywords
Author: somlor - WickedFire
Version: 0.1
*/

function replace ($text) {

 if(!is_page()) {
   $text = str_replace('keyword1', '<a href="http://www.myaffiliatelink1.com/">my link</a>', $text);
   $text = str_replace('keyword2', '<a href="http://www.myaffiliatelink2.com/">my link</a>', $text);
   $text = str_replace('keyword3', '<a href="http://www.myaffiliatelink3.com/">my link</a>', $text);
 }  
 return $text;
}

add_filter('the_content', 'replace');

?>
 
Status
Not open for further replies.