• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

Shortcode with Wordpress Google Website Optimizer Plugin ...

First of all, props to Chris who first suggested the fix to the Wordpress Google Website Optimizer Plugin in the comments on my Wordpress Displaying Code in Square Brackets post. Chris shares his ideas on how to make money online at The Net Hustle.

If you’re having trouble getting the Google Website Optimizer plugin to work with shortcode (code in square brackets that you insert into your posts add plugin functionality), then you need to change the echo statements to return statements in the google-website-optimizer-for-wordpress.php file.

I added some other modifications to the script to make it easier to read. I only just started testing it, but I’m pretty confident the code below will work without modification.

Copy the code and replace the function of the same name in google-website-optimizer-for-wordpress.php (everything between the two lines that start with add_action, but not including the add_action lines).


function go4wp_tracking_script($content) {
  global $wp_query;
  if (is_single() or is_page()) {
    if ($wp_query->post) {
      $post = $wp_query->post;
      $tracking = get_post_meta($post->ID, go_tracking_script_test, true);
      $conversion = get_post_meta($post->ID, go_tracking_script_conversion, true);  //this line got edited after original post
      //if the page/post has both test and conversion code, display both
      if (get_post_meta($post->ID, go_tracking_script_test, true) && get_post_meta($post->ID, go_tracking_script_conversion, true)) {      
        return $content.$tracking.$conversion;
      //if the page/post has test code display it
      } else if (get_post_meta($post->ID, go_tracking_script_test, true)) {
        return $content.$tracking;
      //if the page/post has conversion code, display it
      } else if (get_post_meta($post->ID, go_tracking_script_conversion, true)) {
        return $content.$conversion;
      //if the page/post does not have test and/or conversion code, display the normal content
      } else {
        return $content;
      }
    }
  } else {
      return $content;
      }
}

 Original Source:
http://www.damongudaitis.com/wordpress/shortcode-google-website-optimizer-plugin.html

AddThis Social Bookmark Button

Posted at 11:46:49 am | Permalink | Posted in WordPress Plugins  

Related Stuff

Add Google Search to Your WordPress Blog

The native WordPress search does not return very relevant results, thus it makes a lot of sense to add Google Search into your WordPress ...

Add More Sidebars to Your WordPress Theme

You can add more than one sidebar section to your WordPress site. For example, with the stc-intermountain.org site, I added a whole bunch ...

Series Posting in Wordpress

In my functions.php file, I have some code which implements series posting. This relies on the thematic ...

10 Alternative Uses for WordPress

WordPress is the best and most popular blogging platform around. It’s free, easy to use, endlessly customizable and supported by ...

Using Google Code libraries with WordPress

By default, WordPress loads the version of jQuery that comes with the package. But there is an alternative way of doing it and that’s ...

Top Stuff

Free Blogger templates Anime Themes

Wordpress Guestbook Generator Plugin

48 Unique Ways To Use WordPress

GeekLog

WordPress Single Post Templates

Zookoda



About Webloglines

Webloglines is a project offers a comprehensive collection of blogging services, articles, themes and plugins from around the world. Whether you're looking to promote your own blog or find blogs on various topics, this site is for you.


Search


Topics

  • Adsense (12)
  • Blogging Tips (73)
  • Blogs Slides (25)
  • Blogs Websites (22)
  • Digg (20)
  • How to Blog (129)
  • Search Engines (9)
  • SEO (135)
  • WordPress Plugins (267)
  • WordPress Security (75)
  • Wordpress Themes (99)
  • Wordpress Tips (162)

© 2006 www.webloglines.com. All Rights Reserved. Powered by IRange