Add a wp editor to custom plugin and save data

Solved it! Hope somebody else can use it or it answers their problem. If there is a better way please share and tell why. $editor_id = ‘custom_editor_box’; $uploaded_csv = get_post_meta( $post->ID, ‘custom_editor_box’, true); wp_editor( $uploaded_csv, $editor_id ); To save the data: function save_wp_editor_fields(){ global $post; update_post_meta($post->ID, ‘custom_editor_box’, $_POST[‘custom_editor_box’]); } add_action( ‘save_post’, ‘save_wp_editor_fields’ ); And that’s … Read more

Retrieve multiple values passed to a single attribute in a shortcode

The solution below will parse the comma separated values passed to the shortcode’s type parameter. We’ll also strip out any whitespace surrounding the values which is a usability improvement (see example 2 after the code below). add_shortcode( ‘related’, ‘wpse_related’ ); function wpse_related( $atts, $content=”” ) { // User provided values are stored in $atts. // … Read more

How to insert PHP code in a WordPress Post

You cannot save raw PHP inside post content, it gets cleaned out on save. This is an obvious security precaution. However, there are plugins that will enable you to do this, for example: http://wordpress.org/extend/plugins/allow-php-in-posts-and-pages/ This is not recommended though, better solution would be to create a generic shortcode for your from.

Woocommerce -How to set product regular price default

You could run a check on the save_post hook, but WooCommerce already has a hook for processing meta where the post type and security checks have already been done. So using their hook, you just check for a null string on the regular price and set it to 0. function wpa104760_default_price( $post_id, $post ) { … Read more

Why does $_SESSION only work when I am logged in?

WordPress doesn’t use PHP sessions, so WordPress itself can not be related with your sessions working or not regarding if you are logged in or not (I think). Try to call session_start() on init action instead of doing it in a template file and be sure it is called before your custom library is loaded. … Read more