Title: Adding Fields
Last modified: August 19, 2016

---

# Adding Fields

 *  [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/)
 * I’m finding it rather difficult to add fields to functions.php for P2.
 * Really, all I want to do is add a TITLE input… So users can put a title on their
   posting. I see that P2 figures out the TITLE for you.
 * I also saw the other post where someone makes it the first line in your post.
   This isn’t good enough for me. I don’t want to have to “teach” my subscribers
   anything! It’s also funny to me that the title function in P2 checks to see if
   your post is a IMAGE or VIDEO… when you don’t have the capability to upload either!!(
   well, I do, now… but not in P2 Original)
 * Once I can figure this out, I want to have other fields, too.
 * Hmmmmmm – I just thought of something while typing this… I removed the TAGs fields…
   I would if I can figure it out by looking at that……..

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Thread Starter [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251845)
 * Hey – I did it!!! I now have a TITLE field.
 * Wow – so what did I do… holy moly – let’s see…………
 * I hope CutNPaste work good here!
 * So first: /inc/p2.js
 * function newPost(trigger) {
    var thisForm = $(trigger.target); var thisFormElements
   = $(‘#posttext, #tags, **#my_title**, :input’,thisForm).not(‘input[type=hidden]’);
   var submitProgress = thisForm.find(‘span.progress’); var posttext = $.trim($(‘#
   posttext’).val());
 *  if(jQuery(‘.no-posts’)) jQuery(‘.no-posts’).hide();
 *  if (“” == posttext) {
    $(“label#posttext_error”).text(‘All fields are required’).
   show().focus(); return false; } **var my_title = $.trim($(‘#my_title’).val());
   if (“” == my_title) { $(“label#posttext_error”).text(‘You need to add a TITLE’).
   show().focus(); return false; } toggleUpdates(‘unewposts’); if (typeof ajaxCheckPosts!
   = “undefined”) ajaxCheckPosts.abort(); $(“label#posttext_error”).hide();
 *  thisFormElements.attr(‘disabled’, true);
    thisFormElements.addClass(‘disabled’);
 *  submitProgress.show();
    var tags = $(‘#tags’).val(); if (tags == p2txt.tagit)
   tags = ”; var args = {action: ‘prologue_new_post’, _ajax_post:nonce, posttext:
   posttext, **my_title: my_title**, tags: tags}; var errorMessage = ”; $.ajax({
   type: “POST”, url: ajaxUrl, data: args, success: function(result) { if (“0” =
   = result) errorMessage = p2txt.not_posted_error;
 *  $(‘#posttext’).val(”);
    **$(‘#my_title’).val(”);** $(‘#tags’).val(p2txt.tagit);
 *  Thread Starter [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251855)
 * Well – every where you see “my_title”
 * I also did the functions.php and added stuff:
 *     ```
       function prologue_new_post() {
               if( 'POST' != $_SERVER['REQUEST_METHOD'] || empty( $_POST['action'] ) || $_POST['action'] != 'prologue_new_post' ) {
                   die();
               }
               if ( !is_user_logged_in() ) {
                       die('<p>'.__('Error: not logged in.', 'p2').'</p>');
               }
               if( !current_user_can( 'publish_posts' ) ) {
                       die('<p>'.__('Error: not allowed to post.', 'p2').'</p>');
               }
   
               check_ajax_referer( 'ajaxnonce', '_ajax_post' );
   
               $user_id                = $current_user->user_id;
               $post_content   = $_POST['posttext'];
               $post_title     = trim( $_POST['my_title'] );
   
               //$tags                 = trim( $_POST['tags'] );
               //if ( $tags == __('Tag it', 'p2') || $tags == 'Tag it' ) $tags = '';
   
               //$post_title = prologue_title_from_content( $post_content );
   
               $post_id = wp_insert_post( array(
                       'post_author'   => $user_id,
                       'post_title'    => $post_title,
                       'post_content'  => $post_content,
                       'post_status'   => 'publish'
               ) );
   
               echo $post_id? $post_id : '0';
               exit;
       }
       ```
   
 * There’s only one line here. And Comment out the part where it’s derived from 
   the Content…
 * OH, I disabled TAGs, BTW… so be sure you uncomment that above if you want it…
   I may have deleted some lines, too…
 * Make a BACKUP!!
 *  Thread Starter [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251856)
 * Don’t you love when people solve their own crap!?!?! LOL
 *  Thread Starter [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251858)
 * Now I need to figure out the tabindex order… and how the posttext field gets 
   focus on refresh… cuz then the tabindex gets out of order!!
 *  Thread Starter [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251859)
 * OH – and I almost forgot – you of course have to add the HTML part to the form:
 *     ```
       TITLE: <input id="my_title" type="text" autocomplete="off" value="" tabindex="1" size="30" name="my_title"/>
       ```
   
 *  Moderator [cubecolour](https://wordpress.org/support/users/numeeja/)
 * (@numeeja)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251860)
 * Not sure installation is the best forum for this, but this is an interesting &
   useful tip. Ta for sharing.
 *  [chucksanders](https://wordpress.org/support/users/chucksanders/)
 * (@chucksanders)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251861)
 * thanks for the tip
 *  Thread Starter [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251862)
 * functions.php – i posted some code above (without the code tics!)
 * And sorry about the placement… I thought this was the area for ALL P2 related
   stuff…
 * I’ll see about looking where else to put this…
 *  Thread Starter [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251864)
 * OH – I see what you mean by the wrong place to post this!!!
 * I’m really sorry folks. I began this post in the P2 Theme area and I assumed (
   and you know what they say about those who assume) it would post to the same “
   current” location by default.
 * Not very intuitive, IMHO…
 * Is there a moderator who can move this to the right location?
 *  Thread Starter [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251865)
 * ok – weird, still… I’m in this:
    [http://wordpress.org/tags/p2](http://wordpress.org/tags/p2)
 * and I see my post there… as a tag??…
 * This whole concept of tags is strange to me, which is why I removed TAGs from
   my P2 themed site! HAHA
 *  Thread Starter [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * (@dlopeman)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251874)
 * well – back to the topic – even if it IS in the wrong place (which probably because
   I actually ADDED tags…)
 * Be sure to limit the number of characters. P2 already had for the other function,
   because it would strip 40 characters off the $content… Well – I’ll figure out
   how to apply that to my mods.
 * It’s something I wanted to do to the content, too, anyway!!! I don’t need long-
   winded descriptions of the women drinking beer pix!!!
 * If you are curious, then join in the fun!
    [http://www.womendrinkingbeer.com](http://www.womendrinkingbeer.com)
 * 🙂

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Adding Fields’ is closed to new replies.

## Tags

 * [input](https://wordpress.org/support/topic-tag/input/)
 * [input field](https://wordpress.org/support/topic-tag/input-field/)
 * [title](https://wordpress.org/support/topic-tag/title/)

 * In: [Installing WordPress](https://wordpress.org/support/forum/installation/)
 * 11 replies
 * 3 participants
 * Last reply from: [dlopeman](https://wordpress.org/support/users/dlopeman/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/adding-fields/#post-1251874)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
