PHP in post content

I’m pretty new to WordPress and I’m a bit stuck.

I have created a site and I’m linking to Amazon. I read their ToS and I’m not allowed to hardcode the price in because of price fluctuations. I signed up to the API and got my key and have programmed a function to query the API for the price of an item using the ASIN. This works fine, but when I try to use it in a post it doesn’t work.

I downloaded the “Insert PHP” plugin so I can use shortcode to call my function and echo out the price.

This works partially, but when I echo the returned string it’s wrapped in <p> tags so I cannot echo it out in a <h2> tag properly.

How can I get this to work? Is there a way I can echo it out without being wrapped in the <p> tags?

Thanks

Solutions Collecting From Web of "PHP in post content"

It was a stupid question, I just realized, if I just create a custom shortcode for it, the plugin will not wrap it in <p> tags then, or even better still just create it as a plugin of it’s own.

Have you considered using a plugin for the whole integration? Not sure if you’re doing something more customized than affiliate products though.