• Hi, I’m trying to add a bibliography field to my post/edit page as a wp_editor() (rich text/HTML) field. However, when it gets saved as a post meta custom field, it all gets collapsed into one paragraph – italic formatting, links, and that sort of thing stick around because those get translated into <em> and <a> tags from the rich text, but <p> tags aren’t generated. How can I fix this so that I’m able to have bibliography items on separate lines?

    Here’s my code:

    add_action( 'edit_form_advanced', 'reference_editor' );
    function reference_editor() {
    	// get and set $content somehow...
    	$settings = array( 'wpautop' => true, 'media_buttons' => false );
    	wp_editor( get_post_meta(get_the_id(), 'references', true), 'references', $settings);
    }
    
    add_action( 'save_post', 'save_post', 10, 2 );
    function save_post( $post_id, $post ) {
      if ( !current_user_can( 'edit_post', $post_id ) )
        return $post_id;
    
      update_post_meta( $post_id, 'references', stripslashes( $_POST['references'] ) );
    
    }
Viewing 1 replies (of 1 total)
  • Thread Starter rmaxfiel

    (@rmaxfiel)

    Note that it also doesn’t work if I write it as:
    wp_editor( wpautop(get_post_meta(get_the_id(), 'references', true)), 'references', $settings);

    or
    wpautop(wp_editor( get_post_meta(get_the_id(), 'references', true), 'references', $settings));

    • This reply was modified 5 years, 11 months ago by rmaxfiel.
Viewing 1 replies (of 1 total)
  • The topic ‘WP Editor to post meta – no paragraph tags’ is closed to new replies.