• Resolved Atif

    (@wwwmixhungamacom)


    I have the following custom made front end form to add new posts. I want to include SEO Ultimate meta title, description and keywords fields in the form, so I will not have to go every time to the dashboard to add them and it will be easy to add the meta details directly using my custom made front end form. How do I integrate SEO Ultimate meta title, description and keywords fields in the following form?

    <?php
    if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {
    
        // Do some minor form validation to make sure there is content
        $title = $_POST["title"];
        if(!empty($_POST['middle'])) {
        $description = 'a sentence ' . $_POST['middle'] . ' with something in the MIDDLE. a sentence ' . $_POST['end'] . ' with something in the END.';
        }
        $tags = $_POST["tags"];
        $post_cat = $_POST['cat'];
    
        // ADD THE FORM INPUT TO $new_post ARRAY
        $new_post = array(
        'post_title'    =>  $title,
        'post_content'  =>  $description,
        'post_category' =>  $post_cat,  // Usable for custom taxonomies too
        'tags_input'    =>  $tags,
        'post_status'   =>  'draft',           // Choose: publish, preview, future, draft, etc.
        'post_type' =>  'post',  //'post',page' or use a custom post type if you want to
        );
    
        //SAVE THE POST
        $pid = wp_insert_post($new_post);
    
        //REDIRECT TO THE NEW POST ON SAVE
        $link = get_permalink( $pid );
        wp_redirect( '/post-submitted-draft' );
    
    } // END THE IF STATEMENT THAT STARTED THE WHOLE FORM
    
    //POST THE POST YO
    do_action('wp_insert_post', 'wp_insert_post');
    
    ?>

    http://wordpress.org/extend/plugins/seo-ultimate/

    [ Please do not bump, it’s not permitted here. ]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor John

    (@johnlamansky)

    Hi Atif,

    First, you’ll need to add the code for title/description/keyword fields to your front-end form. Then, after the wp_insert_post command, insert add_post_meta calls that look something like this:

    add_post_meta($pid, '_su_title', $_POST['_su_title'], true);
    add_post_meta($pid, '_su_description', $_POST['_su_description'], true);
    add_post_meta($pid, '_su_keywords', $_POST['_su_keywords'], true);
    Thread Starter Atif

    (@wwwmixhungamacom)

    I added your given lines just after wp_insert_post as shown below:

    //SAVE THE POST
    $pid = wp_insert_post($new_post);
    add_post_meta($pid, '_su_title', $_POST['_su_title'], true);
    add_post_meta($pid, '_su_description', $_POST['_su_description'], true);
    add_post_meta($pid, '_su_keywords', $_POST['_su_keywords'], true);

    After that I added su_title in $new_array as shown below:

    // ADD THE FORM INPUT TO $new_post ARRAY
    $new_post = array(
    'post_title'	=>	$title,
    '_su_title'	=>	$su_title,
    'post_content'	=>	$description,
    'post_category' =>	$post_cat,
    'tags_input'	=>	$tags,
    'post_status'	=>	'draft',
    'post_type'	=>	'post',
    );

    and for getting the value of title from the form I added the following line:

    $su_title = $_POST["SuTitle"];

    and added input name as SuTitle. I did according to your instructions as I understand but nothing works. Am I doing anything wrong?

    Thread Starter Atif

    (@wwwmixhungamacom)

    Thanks. I got your instructions now and I resolved the issue by using the input name “_su_title” in the field as you already mentioned the value of ‘_su_title’ in add_post_meta as $_POST[‘_su_title’].

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘SEO Ultimate Meta in Custom Made Front End Form’ is closed to new replies.