Skip Navigation

[Resolved] Amazon URL in post body rendering as Kindle Preview

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 1 voice.

Last updated by davidL-7 17 hours, 30 minutes ago.

Assisted by: Minesh.

Author
Posts
#2834440
Screenshot 2025-11-10 at 11.23.20 AM.png
Screenshot 2025-11-10 at 11.22.50 AM.png

The system we're building with Toolset helps park staff procure funds for products they need to order. Sometimes they are ordering from Amazon and drop in an Amazon URL into the product description field of the order form. This field gets stored as the post body.

The problem is that when the view renders the page, the URL renders as a Kindle preview (very strange, as it's not a Kindle product).

You can view the issue at hidden link (you'll need to log in first).

I expected to see:
The raw URL rendered as text. See value of field in the post in screenshot.

Instead, I got:
A Kindle preview, see screenshot.

I thought that surpressing third-party filters might remedy it, and used [wpv-post-body view_template="None" suppress_filters="true"] to render the field, but that didn't work.

To help with your diagnosis, here's how it's constructed:
1) The page linked to above (which you can also navigate to by going to Aid Requests and editing request 2025 - 130) uses content template 30233, which drops in the view 30274.
2) View 30274 gets a custom post type Aid Items, and you can view the Aid Item post with the body in question at hidden link (see Loop Editor, line 60)
3) Note that the Item Description field is deprecated and not in use, but the same content that gets filled out by the park staff is getting written to it. If you compare Item Description against the post body, you'll see the Item Description has a much longer query string. I shaved the query string off the URL in the body, since it wasn't essential, to see if would solve the issue, but it did not.

Any idea how I can keep URL content from rendering like this?

#2834516

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I've added the following code snippet namely "show-content-in-plaintext" to the "Custom Code" sectinon offered by Toolset:
=> hidden link

function func_plaintext_if_amazon_link( $atts ) {
    global $post;
    if ( ! isset( $post->post_content ) ) {
        return '';
    }

    // Get post content
    $content = $post->post_content;

    // Check if amazon.com link exists (case-insensitive)
    if ( stripos( $content, 'amazon.com' ) !== false ) {
        // Convert to plain text
        $plain_text = wp_strip_all_tags( $content );
        // Optional: Trim and clean spacing
        $plain_text = trim( preg_replace( '/\s+/', ' ', $plain_text ) );

        return esc_html( $plain_text );
    }

    // If no amazon.com link found, return nothing (or custom message)
    return $content;
}
add_shortcode( 'show_content_plain_text', 'func_plaintext_if_amazon_link' );

Can you please confirm it works as expected.

#2834595

Thanks Minesh, that did the trick! I didn't think to approach it like that, but your solution works brilliantly. Obviously it will only work on URLs with 'amazon.com' in them, but I don't anticipate that we'd get the same behavior from non-Amazon URLs, so I'm happy with this solution.

Thanks again!
David