Dynamically inserting keywords into Wordpress posts?

Status
Not open for further replies.

ImagesAndWords

StayblCam.com
Nov 7, 2006
2,326
90
0
Scottsdale, Arizona
www.stayblcam.com
Lately I have been having serious trouble with super-high bids and fucked up QS on Adwords, which I talked more about here.

What I want to do now is to build a Wordpress based platform for my revamped affiliate site. My previous version of it was purely php-driven, with a database for tracking ids.

I'm gonna skip the tracking part of it for now. Right now I just wanna get my site live with Adwords again and shoot for a non-insane quality score.

I have ran into a problem with Wordpress though:
I want to grab parameters from the post URL and insert the parameter as a variable dynamically into my WP posts and/or pages.

So that when I call one of my blog posts like this:
Code:
hxxp://www.mybadblog.com/landingpage-post.php?keyword=quality score my ass
…I can then grab the keyword using $_GET and insert it where I want to in the post or tags dynamically.

As many of you probably know though, Wordpress doesn't natively support php in posts. There are workarounds to this, most notably with a plugin such as exec-PHP

This will let me do simple things like
Code:
<?php echo "This is the Exec-PHP 'Hello World'"; ?>
But it doesn't work with statements like
Code:
<?php echo ucwords(str_replace("-", " ", $_GET["keyword"])); ?>
WP doesn't accept that but instead comes up with "Sorry, there are no posts that match your criteria"

Does anyone know how to pull this off?
I would be very thankful! :bowdown:

Ideally, I would also love to be able to insert the keyword into the post Title or even Meta description but that might be even trickier.. :)
 


Quick response (without me taking the time to really really research it) is: you have to hook into that functionality of WordPress.

Basically, make a function that pulls the $_GET variable. Then, tell WP about your brand new function like....

PHP:
add_action ( 'hook_name', 'your_function_name', [priority], [accepted_args] );

PLay around with that and I have faith in your abilities to eventually get it working. :) (I just don't have time right now...some parades are about to start and I have to go...it's Mardi Gras here in New Orleans....)
 
I'm not sure if this will work for you, but why not skip messing with the WP loop and do something like this.

PHP:
<?php
$kw = $_GET['keyword'];
$data = file_get_contents('wp-landingpage');
$data = str_replace('-', $kw, $data);
echo $data;
?>
This way you don't have to piss around with WP's code and if you wanna change the Meta tags and title it will also be easy.
 
I have run into similar problems with exec-php. the simplest thing for me was just to hack up the post template with the PHP I wanted and then go from their. Not as elegant as building a WP function to do it, but still works.
 
Quick response (without me taking the time to really really research it) is: you have to hook into that functionality of WordPress.

Basically, make a function that pulls the $_GET variable. Then, tell WP about your brand new function like....

PHP:
add_action ( 'hook_name', 'your_function_name', [priority], [accepted_args] );
PLay around with that and I have faith in your abilities to eventually get it working. :) (I just don't have time right now...some parades are about to start and I have to go...it's Mardi Gras here in New Orleans....)

That's interesting. I'm afraid my php skills aren't quite that advanced yet though. :) :anon.sml:

Maybe someone would be willing to code it for me for $$$ ;)
 
Status
Not open for further replies.