Wordpress Hooks + Php question
First post. I am trying to make my own little plugin : ).
1) What I am trying to accomplish:
-I want the plugin to save options when you click "update" in the edit page/post in the admin area.
Here is my little code:
====
add_action('save_post', 'myplugin_save_postdata'); // <-- this doesn't work the way I want it to , as in it doesn't call the function, I think, when I click "update" or "publish"
function myplugin_save_postdata( $post_id ) {
?>
<script type="text/javascript">
alert("SAVING POST");
</script>
<?php
$mydata = $_POST['myplugin_new_field'];
add_option('my_option', $mydata, '', 'yes');
update_option('my_option', $mydata, '', 'yes');
}
====
The thing is, it doesn't work. I click update the post, and there is no javascript alert box.
2) I want to echo <img src="lalala/img.png"> without it actually showing the picture.
In other words, I want it to echo the text <img src="lalala/img.png">, and not the picture lalala/img.png.
Can anyone help me .
-Subscribe to my free premium wordpress plugin giveaway. SUBSCRIBE NOW