Support » Fixing WordPress » Add an extra text input field on admin post page

  • Resolved Matt

    (@webmasterifcj)


    Hello,

    What i would like to do is add another section of the admin post page template that would allow for a second excerpt of sorts.

    With this new field I would like to display this extra excerpt on our home page. The excerpt that is already available to us is being used right now and we would like to add an extra one.

    Is this an easy thing to do?

Viewing 8 replies - 16 through 23 (of 23 total)
  • I think that’s due to how the media buttons operate with the ajax, which sends the data to an element defined in this line..

    edCanvas = document.getElementById('content');

    However it’s not a simple case of changing that line (that would prevent the regular media buttons on the page from working).

    Then it’s not the every day average question you’re asking. If i find something to fix the issue i’ll post it, but in the mean time my only suggestion would be to just copy+paste the output across from the content area to the new box.

    lol, it was actually easier then i thought, just redeclare the var after the media buttons like so…

    And it’ll go into the correct box.. (just update this function)

    function my_post_meta_box( $object, $box ) { ?>
        <p>
        	<?php if ( current_user_can( 'upload_files' ) ) : ?>
               <div class="hide-if-no-js">
    		   <?php do_action( 'media_buttons' ); ?>
               </div>
               <?php endif; ?>
            <br />
    		<label for="second-excerpt">Second Excerpt With Images for Post List Page</label>
    		<textarea name="second-excerpt" id="second-excerpt" cols="60" rows="4" tabindex="30" style="width: 97%;"><?php echo wp_specialchars( get_post_meta( $object->ID, 'Second Excerpt', true ), 1 ); ?></textarea>
    		<input type="hidden" name="my_meta_box_nonce" value="<?php echo wp_create_nonce( plugin_basename( __FILE__ ) ); ?>" />
    		<script type="text/javascript">edCanvas = document.getElementById('second-excerpt');edInsertContent = null;</script>
    	</p>
    <?php }

    You’ll notice i removed the ID from the media buttons div in the function. Reason being, that ID exists on the page, so it needs a new one, or just the old one removed (add some additional CSS to match the other if you want it to match).

    Spoke to soon, broke the top media buttons, lol… i should test more thoroughly before posting..

    Got the right idea, just need to figure how to have 2 vars with the one script, bear with me..

    Looking at how media buttons operate on the posts page, it’s not going to work while the other is present…

    They’re not designed to be on the page twice, and i can’t see any way to modify it to support 2, at least not without several additions all over the place.

    Think about it, the uploader is designed to send data to one place, the post page, and specifically that ordinarily only has one place that supports shortcodes (ie. [caption][gallery] and so on).. so there’s never been a case where it would need to support more then one area.

    Above approach i mentioned would change where the code gets pasted/inserted, but as i mentioned this then also effects the media buttons that normally placed regular inserts into the content area.

    It’s either, or…i’m affraid ..

    Unless someone with more knowhow of WP js and jquery can chime in and suggest something more..

    If there were a JS script equivalent of add_action/add_filter then i’m sure it would be possible (with the right know how – beyond my capabilities as it stands though).

    Thread Starter Matt

    (@webmasterifcj)

    t31os_,

    I see what your saying. I will look over this and if I find something I will post it as soon as I come up with something.

    I will for now have the author just copy and paste the syntax from the main area to the second excerpt area.

    Thanks for helping out.

    You’re welcome, sorry i couldn’t help more.. 😉

    Thread Starter Matt

    (@webmasterifcj)

    Okay let me ask this question. Is there a way that I can set up this meta box to recognize markup.

    What I mean by that is we have contributors that are not very HTML savvy and type freely. I would like this box to recognize white space and or line breaks.

    Thanks ahead of time

    try the plugin different-type … it is german but you can see the image, source and the zip file

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Add an extra text input field on admin post page’ is closed to new replies.