WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] the_editor($content) and wp_editor($content) not displaying read more tags (3 posts)

  1. Spike
    Member
    Posted 2 years ago #

    I was writing my own plugin that uses the_editor(). I have found wp_editor() too, however they both function the same in this regard.

    If a user enters a post (from inside my plugin) with a read more tag, it works fine when viewing the post.

    When accessing the post again inside my plugin, the read-more tag is lost. Instead, in html view it is displayed as this: <span id="more-38"></span>. It is completely lost in visual mode and disappears from the html view if you flip between the two views.

    Here's the code in the plugin that calls the content and places it into the editor. The content is displayed correctly inside of the editor, but the readmore is no longer functional, and if the post is submitted again without replacing the read more it is lost.

    Would be ideal if the_editor() functioned how it does when creating a post!

    <?php global $more;    // Declare global $more (before the loop). ?>
    
    <?php $more = 1;       // Set (inside the loop) to display all content, including text below more. ?>
    
    <?php
    $content = get_the_content();
    wp_enqueue_script(array('jquery', 'editor', 'thickbox', 'media-upload'));
    wp_enqueue_style('thickbox');
    ?>
    
    <?php the_editor($content);?>
  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    afaik, get_the_content() already applies some filters;

    (see /wp-includes/post-template.php line171++ )

    possibly try to use $post->post_content instead (maybe with global $post; before it).

  3. Spike
    Member
    Posted 2 years ago #

    Resolved! Thank you. Here's the code I inserted for anyone curious.

    <!-- Inside the loop -->
    <?php
    global $post;
    wp_enqueue_script(array('jquery', 'editor', 'thickbox', 'media-upload'));
    wp_enqueue_style('thickbox');
    ?>
    
    <?php the_editor($post->post_content);?>

    I was able to remove the global more and setting more to 1 as well since I was calling post_content. Thanks again.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.