Problem with wp_editor

时间:2014-03-04 作者:user112212

我试图添加wp_editor 但没有成功。有人能帮我在“故事”字段中添加wp\\U编辑器吗。。

    function guestposts_shortcode( $atts ) {
    extract ( shortcode_atts (array(
        \'cat\' => \'1\',
        \'author\' => \'1\',
        \'thanks\' => get_bloginfo(\'home\'),
    ), $atts ) );

    return \'<form class="guests-post" action="\'. plugin_dir_url("guest-posts.php") .\'guest-posts/guest-posts-submit.php" method="post">
        <strong>\' . __(\'Post Title:\', \'guest-posts\') . \'</strong><br>
            <input type="text" name="title" size="60" required="required" placeholder="\' . __(\'Post title here\', \'guest-posts\') . \'"><br>
        <strong>\' . __(\'Story\', \'guest-posts\') . \'</strong>
        \'. wp_nonce_field() .\'
            <textarea rows="15" cols="72" required="required" name="story" placeholder="\' . __(\'Start writing your post here\', \'guest-posts\') . \'"></textarea><br>
        <strong>\' . __(\'Tags\', \'guest-posts\') . \'</strong><br>
            <input type="text" name="tags" size="60" placeholder="\' . __(\'Comma Separated Tags\', \'guest-posts\') . \'"><br><br>
        <strong>\' . __(\'Your Name\', \'guest-posts\') . \'</strong><br>
            <input type="text" name="author" size="60" required="required" placeholder="\' . __(\'Your name here\', \'guest-posts\') . \'"><br>
        <strong>\' . __(\'Your Email\', \'guest-posts\') . \'</strong><br>
            <input type="email" name="email" size="60" required="required" placeholder="\' . __(\'Your Email Here\', \'guest-posts\') . \'"><br>
        <strong>\' . __(\'Your Website\', \'guest-posts\') . \'</strong><br>
            <input type="text" name="site" size="60" placeholder="\' . __(\'Your Website Here\', \'guest-posts\') . \'"><br><br><br>
        <input type="hidden" value="\'. $cat .\'" name="category"><input type="hidden" value="\'. $author .\'" name="authorid">
        <input type="hidden" value="\'. $thanks .\'" name="thanks">
        <input type="hidden" value="\'. str_replace(\'/wp-content/themes\', \'\', get_theme_root()) .\'/wp-blog-header.php" name="rootpath">
        <input type="submit" value="\' . __(\'Submit The Post\', \'guest-posts\') . \'"> <input type="reset" value="\' . __(\'Reset\', \'guest-posts\') . \'"><br>
        </form>
        \';
    }
add_shortcode( \'guest-posts\', \'guestposts_shortcode\' );

?>
这是提交。php

    <?php

//Get the submitted form
ob_start();
require_once($_POST["rootpath"]);
$title = $_POST["title"];
$story = $_POST["story"];
$tags = $_POST["tags"];
$author = $_POST["author"];
$email = $_POST["email"];
$site = $_POST["site"];
$authorid = $_POST["authorid"];
$category = $_POST["category"];
$thankyou = $_POST["thanks"];
$path = $_POST["rootpath"];
$nonce=$_POST["_wpnonce"];

//Load WordPress
//require($path);

//Verify the form fields


   //Post Properties
    $new_post = array(
            \'post_title\'    => $title,
            \'post_content\'  => $story,
            \'post_category\' => $category,  // Usable for custom taxonomies too
            \'tags_input\'    => $tags,
            \'post_status\'   => \'pending\',           // Choose: publish, preview, future, draft, etc.
            \'post_type\' => \'post\',  //\'post\',page\' or use a custom post type if you want to
            \'post_author\' => $authorid //Author ID
    );
    //save the new post
    $pid = wp_insert_post($new_post);

    /* Insert Form data into Custom Fields */
    add_post_meta($pid, \'author\', $author, true);
    add_post_meta($pid, \'author-email\', $email, true);
    add_post_meta($pid, \'author-website\', $site, true);

header("Location: $thankyou");
?>

1 个回复
SO网友:Jonathan

wp\\U编辑器回显包含文本区域的编辑器。因此,只需将文本区域替换为<?php wp_editor($content, $id, $args); ?> 并根据需要设置参数。

https://codex.wordpress.org/Function_Reference/wp_editor

结束

相关推荐

How to find installed plugins

我一直在寻找WordPress网站上安装的插件列表。虽然我找到了一种方法,“http wp plugins.nse”暴力脚本,但我不知道如何使用这个脚本。如果有人知道任何方法,请分享。