Support » Installing WordPress » 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)
  • 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 = $(;
    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;
    if (typeof ajaxCheckPosts != “undefined”)

    thisFormElements.attr(‘disabled’, true);
    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 = ”;
    type: “POST”,
    url: ajaxUrl,
    data: args,
    success: function(result) {
    if (“0” == result)
    errorMessage = p2txt.not_posted_error;


    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' ) {
            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';

    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!!

    Don’t you love when people solve their own crap!?!?! LOL

    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!!

    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



    Not sure installation is the best forum for this, but this is an interesting & useful tip. Ta for sharing.

    thanks for the tip

    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…

    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?

    ok – weird, still… I’m in this:

    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

    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!


Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Adding Fields’ is closed to new replies.