• Plans & Pricing
  • Log in
  • Get started
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress 
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Get started
  • Sign up
  • Log in
About
  • Plans & Pricing
Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress  
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Jetpack App
  • Learn more
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Search
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Forums / WP Editor to post meta – no paragraph tags

WP Editor to post meta – no paragraph tags

  • Unknown's avatar
    rmaxfiel · Member · Apr 12, 2019 at 3:31 pm
    • Copy link Copy link
    • Add topic to favorites Add topic to favorites

    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...
    	echo "";
    	echo "References";
    	echo "";
    	$settings = array( 'wpautop' => true, 'media_buttons' => false );
    	wp_editor( get_post_meta(get_the_id(), 'references', true), 'references', $settings);
    	echo "";
    }
    
    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'] ) );
    
    }
  • Unknown's avatar
    supernovia · Staff · Apr 12, 2019 at 5:42 pm
    • Copy link Copy link

    Hi @rmaxfiel, can you confirm what site you’re working on? It sounds like you’re likely developing using your own installation of WordPress.org, and these forums are actually for the sites hosted on our servers.

    Our service is different from the free software project. So for help with the free software, I’d recommend checking the support forum here:
    https://wordpress.org/support/forums/

    Good luck!

  • Unknown's avatar
    rmaxfiel · Member · Apr 12, 2019 at 6:26 pm
    • Copy link Copy link

    My apologies, yes, this is for a local installation. I could have sworn I’d posted this in .org support but apparently not. Thank you!

  • The topic ‘WP Editor to post meta – no paragraph tags’ is closed to new replies.

Tags

  • custom fields
  • functions.php
  • post meta
  • wp_editor

About this topic

  • In: Support
  • 2 participants
  • 2 replies
  • Last activity 7 years
  • Latest reply from rmaxfiel

Couldn't find what you needed?

Contact us

Contact us

Get answers from our AI assistant, with access to 24/7 expert human support on paid plans.

Browse our guides

Browse our guides

Find step-by-step solutions to common questions in our comprehensive guides.

WordPress.com

Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Professional Email
  • Website Design Services
  • WordPress Studio
  • Enterprise WordPress
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • WordPress.com Blog
  • Business Name Generator
  • Logo Maker
  • WordPress.com Reader
  • Accessibility
  • Remove Subscriptions
Help
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
  • Developer Resources
Company
  • About
  • Press
  • Terms of Service
  • Privacy Policy
  • Do Not Sell or Share My Personal Information
  • Privacy Notice for California Users
DeutschEspañolFrançaisBahasa IndonesiaItalianoNederlandsPortuguês do BrasilSvenskaTürkçeРусскийالعربيةעִבְרִית日本語한국어简体中文繁體中文English

Mobile Apps

  • Download on the App Store
  • Get it on Google Play

Social Media

  • WordPress.com on Facebook
  • WordPress.com on X (Twitter)
  • WordPress.com on Instagram
  • WordPress.com on YouTube

Automattic

Automattic
Work With Us
    • WordPress.com Forums
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • Manage subscriptions