Save AND Output simple HTML data to and from database using Wordpress

by HPWD   Last Updated June 18, 2018 02:08 AM

First let me say, I'm overwhelmed so I'm reaching out for some help.

I have a custom form in Wordpress Admin area. One of the form fields (textarea) is using wp_editor.

<?php wp_editor( $content, 'body-content', $settings = array('textarea_rows'=>'10') );

This works great and so far so good. When I am setting up the array to pass to the $wpdb->insert( $my_table, $array_data); is where I'm lost and confused and overwhelmed.

I started out using strip_tags and stripslashes but the output to another page didn't display the desired content.

I then tried htmlentities($_POST['content']); which is saving the data to the database as this is some text with &lt;a href=\&quot;https://www.google.com\&quot;&gt;links&lt;/a&gt;. When I output to the page using html_entity_decode( $array->content ), the link isn't clickable (when I mouseover the text, I see http://localhost:8888/"http://www.google.com". I believe the issue is with the \ not being removed on the output or being added unnecessarily on the saving to the database. If I manipulate the value in the database and remove the \ and then check the output web page again, the text is clickable. I'm so close and just need a little more guidance to help me across the finish line.

UPDATED As a follow up comment, part of what is overwhelming me is I can't figure out if my issue is the way the data is being saved or the way the data is being retrieved and displayed. If the data would save without escaping the double quotes, I think I'd have it.

Tags : wp-editor


Related Questions


&nbsp when I use ENTER for skipping line

Updated March 26, 2015 09:02 AM

How to make shortcode which returns HTML?

Updated May 17, 2015 21:03 PM

disable <script> tags on wordpress text editor

Updated November 08, 2017 16:08 PM

Visual/Text tabs in wp editor Not Showing

Updated August 17, 2016 08:03 AM

Set default "Link CSS Class" in add media admin editor

Updated November 30, 2017 15:08 PM