can't view html content when submit form in wordpress - wordpress

i'm was create a menu and Form in wordpress.
then, i was create form send email for my customer.
it's oke. But my problems is :
I'm writing some thing in editor, add color, font size... for text, add images....
But when echo the result after click submit button, it not show same as in the editor content,
all html code was removed, (the heading form h1 -> h6 is keep).
I want the result of Echo was same as in the forms. (All html was keep)
Help me to solve this problem, Please !
here is my code
<form method="post" id="kaka" name="form_send_mail">
<?php wp_editor('default text', 'idgiday', $settings = array(
'drag_drop_upload' => true,
'editor_height' => '300',
'textarea_name' => 'textarea_name_td'
) );
?>
<imput type="text"></imput>
<input type="submit" value="ok">
</form>
<?php
echo #$_POST['textarea_name_td'];
?>

Actually you need to get the output via editor ID which you have mentioned idgiday ,
echo $_REQUEST['idgiday'];
You can save the editor output via,
add_post_meta($post_id,'idgiday',$_REQUEST['idgiday']);
And then get the output,
get_post_meta($post_id,'idgiday',true);

Related

I can't debug whats wrong with my ACF get_field() to display an image array's url value

So my code is pretty straightforward. I am just getting a field value from the global fields (Options). So this field is on Dashboard -> Options (I have ACFpro) and I am trying to echo out a logo which is an image array.
This is how my code looks like
<ul class="text-white p-0">
<a class="brand " href="/">
<?php
$image = get_field('logo');
echo '<p id="debug">'.($image ['url']).'</p>';
?>
</a>
</ul>
al i am trying to do is pull the url value and insert it to a <p> tag just to make sure it pulls the right value. but instead I am getting this error.
error when trying to echo $image
Any idea on what am I doing wrong?
It is one of two things. You need to add the ID or options to the get_field() as a parameter or you need to adjust the return format. By default it tries to pull the ID of the page get_field() is on.
I would change it to
get_field( 'logo', 'options' );
Or change options to whatever you called your options page.
https://www.advancedcustomfields.com/add-ons/options-page/

How to design a php page theme template in wordpress using either html or css?

<?php
/*
Template Name: isbn
*/
?>
<form action="" method="post" name="myForm">
Filter <input id="isbn" type="text" name="isbn" />
<input type="submit" name="submit" value="Submit" /></form>
<?php get_header(); ?>
<?php
if(isset($_POST['submit']))
{
global $wpdb;
$table_name = "isbn"; // change this to your table name
$field = $_POST['isbn']; // change this to your isbn field $_POST['ISBN'];
$retrieve_data = $wpdb->get_results( "SELECT * FROM $table_name where isbn = '".$field."'");
foreach ($retrieve_data as $retrieved_data) {
echo $retrieved_data->title;
// echo $retrieved_data->image; // for image
}
}
?>
This is a search form which i want to design. I have created this form in a page template named isbn. But when i am opening that page for editing i am unable to do this. I am using divi theme in wordpress.
So divi theme is not allowing me to edit this page. Due to which this page is looking very bad in look wise.
Can anyone help me for designing this page by giving their codes or simply by giving their suggestions?
I am facing one more problem whenever i am writing css code in above code i am not getting anything. So i am totally blank that how to deal with this
Just create a WordPress page and add shortcode which you added in functions.php before. Don't create template for this page just use your shortcode only.
First, you have to create a page using divi theme, then create shortcode for this form in functions.php and then use this shortcode in your page.
you are inserting the form above the get_header(); function, so it will be outside of the html tag and outside of the body tag. Move it into the body, then it should at least appear on the page, and you'll see what you need to do next.

Searching an external website from Wordpress search

I'm trying to change the search functioanlity of a Wordpress website so it searches an external website instead. While I've been able to change the form action to use the external websites URL, I haven't been able to get the right search results. Here is the code I'm using:
<div class="et_search_outer">
<div class="container et_search_form_container">
<form role="search" method="get" class="et-search-form" action="https://www.premierkitchenandbathgallery.com/search.htm?S1=">
<?php
printf( '<input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" />',
esc_attr__( 'Search …', 'Divi' ),
get_search_query(),
esc_attr__( 'Search for:', 'Divi' )
);
?>
</form>
<span class="et_close_search_field"></span>
</div>
As noted above, I'm attempting to search Premiere Kitchen & Bath using https://www.premierkitchenandbathgallery.com/search.htm?S1=
However, every search seems to fail, showing:
"We're Sorry!
Your search for ""
did not match any results.."
So either the search term isn't being passed, or I'm not using the correct search string. Any suggestions? Here is the website I'm searching from, if you want to test - http://premierkitchen.solutioserver.com/ (use search bar in the menu)

Custom metabox for file upload return empty filename

I want to attach a file to a post and "do something with it later". The file isn't being pulled over when I publish/update my post, the error I get is an empty filename. If I change the input type to text and submit I can get the text to save/display but trying to upload the file acts as though I haven't supplied the file to the form:
form --
function display_file_upload_meta_box($post_id,$post){
wp_nonce_field( basename( __FILE__ ), 'file_upload_meta_box_nonce' );
?>
<p>
<?php
$fileUpload= get_post_meta($object->ID,'file-upload-meta',true);
if(!$fileUpload)
$fileUpload = '';
echo 'file: '.$fileUpload;
?>
<label for="file_upload_meta">Attach a file to this post</label>
<input type="file" id="file_upload_meta" name="file_upload_meta" class="widefat"/>
</p>
<?php
}
code to upload file --
$new_meta_value = wp_upload_bits($_FILES["file_upload_meta"]['name'], null, file_get_contents($_FILES["file_upload_meta"]['tmp_name']));
It's probably because the form does not have those attributes :
enctype="multipart/form-data" encoding="multipart/form-data"
You can use a hook to add them, check this : https://gist.github.com/rfmeier/3513349
I got a requirement for adding custom meta boxes for a custom post type in wordpress and I tried using the following plugin and got working for me. Try this

How to create new pages in wordpress admin panel

I am trying to create a separate menu section on wordpress admin panel which will contain three pages. The pages will behave exactly like the normal wordpress pages, I just want to have a separate menu section in the admin panel. I am able to use wp_editor() to display the editor within a form. My problem is how do I get the content from the editor and how do save into the wp_post in the database? Here is the piece of code I have already come up with:
<?php
$content = '';
wp_editor('test', 'mydescription', array('textarea_name' => 'my_description', 'tinymce' => true));
?>
<p><div class="submit"><input type="submit" name="save_front_content_options" value="<?php _e('Save Changes', 'save_options') ?>" style="font-weight:bold;" /></div></p>
<input type="hidden" name="action" value="save" />
</form>
If I understand correctly, you are looking for the Settings API:
Settings API tutorial.
Settings API documentation.

Resources