Rich-text Reply

Cannot link to WordPress with the post_id

brettjenks1 04-10-16

Cannot link to WordPress with the post_id

In trying to utilize the Optimizely WordPress plugin I am running into an error as I cannot return the post_id field. This is required to have the A/B headlines show up on more than just the post page. When I call the post_id it returns empty, rendering the plug in useless.


Has anyone else experienced this?

DavidS 04-11-16

Re: Cannot link to WordPress with the post_id

Hi brettjenks1,


Thanks for reaching out to Optimizely Support!

I understand that you are using the Optimizely WordPress plugin and that you are unable to return the post_id field. 


Could you give me a bit information on what your setup is and how you are calling the post_id field? Why are you looking to call the post_id field yourself? 


The Wordpress plugin should take care of doing the testing on your website for you without the need of any technical skills. 


Let's get to the bottom of this!




brettjenks1 04-12-16

Re: Cannot link to WordPress with the post_id

Hi David-

More information about my setup:

  • I'm running on WordPress 4.4.2
  • I installed and activated the Optimizely plugin and go to the plugin's "Configuation" tab
    • I set up the connection via the Optimizely token (no need to manually add the .js script to the head)
    • Chose the appropriate project
    • Selected the post types I want potential headline testing on
    • Set "Default URL targeting" for my home page
    • Attempted following the documentation on this page. (this is where I run into the error)
  • Set "Activation Mode" at "Immediate"
  • Set "Max # of variants" to 2

The linked support page says that I need to define the class of the anchors as the variable post_ID so that Optimizely can apply the .js to all links in order to change the post headline on all pages that have an A/B test running.


Let me know if I missed something that would aleviate the need for me to update the anchor tag on every .php file that references a post's name (home page, category page, archive page, blog page, etc.)

brettjenks1 04-12-16

Re: Cannot link to WordPress with the post_id

If you would like to take a gander at my home page set up, a link to the php is right here >

David_Orr 04-18-16

Re: Cannot link to WordPress with the post_id

Hi Brett,


Can you provide me with the specific line of code that defines the post id's class?


I looked at your blog's homepage and noticed that each title utilizes the following class "optimizely-(postID)". This means you should be able to modify the "Variation Code" in the Wordpress plugin settings to $(".optimizely-$POST-ID").text("$NEW_TITLE"); and the changes should reflect on the home page. 


If you are still running into issues,  please provide me with the variation code in the Optimizely plugin and create an experiment so I can see what variation code is generated? You may pause the experiment after it is created.




Senior Technical Support Engineer