0

That's my situation right now: enter image description here

I want to display my "Artist" custom field under the "Slug" field, with the same HTML structure. But how? Example: enter image description here

The following code may help:

// Display the custom field
function my_custom_field_add_quick_edit($column_name, $post_type)
{
    if ($column_name != 'Artista')
        return;
    global $post;
    $custom_field_value = get_post_meta($post->ID, 'Artista', true);
    ?>
    <fieldset class="inline-edit-col-right">
        <div class="inline-edit-group">
            <label>
                <span class="title">Artista</span>
                <input type="text" name="Artista" value="<?php echo esc_attr($custom_field_value); ?>" />
            </label>
        </div>
    </fieldset>
<?php
}
add_action('quick_edit_custom_box', 'my_custom_field_add_quick_edit', 10, 2);
// Display the original fields
<fieldset class="inline-edit-col-left">
   <legend class="inline-edit-legend" id="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend>
   <div class="inline-edit-col">
      <?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?>
      <?php if ( $bulk ) : ?>
      <div id="bulk-title-div">
         <div id="bulk-titles"></div>
      </div>
      <?php else : // $bulk ?>
      <label>
      <span class="title"><?php _e( 'Title' ); ?></span>
      <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
      </label>
      <?php if ( is_post_type_viewable( $screen->post_type ) ) : ?>
      <label>
      <span class="title"><?php _e( 'Slug' ); ?></span>
      <span class="input-text-wrap"><input type="text" name="post_name" value="" autocomplete="off" spellcheck="false" /></span>
      </label>
      <?php endif; // is_post_type_viewable() ?>
      <?php endif; // $bulk ?>
      <?php endif; // post_type_supports( ... 'title' ) ?>
   </div>
</fieldset>

Thanks in advance. And don't be rude. I'm new to PHP.

2
  • This looks like it's just a CSS issue... something about the style rules. Also, as you're new to PHP, just a bit of advice... ...when you're using tutorials they'll often name functions stuff like my_custom_blahblahblah... ....change that to something unique to your site. I normally have a prefix that I use across an entire theme or plugin and just use that ie. gutsa_field_add_quick_edit(). Jan 10 at 1:41
  • Can you try to just comment out the <fieldset class="inline-edit-col-right"> and the closing </fieldset> tags for your custom field... ...see if that does it. Either way, I think if you just work through the CSS you'll find the issue pretty quick. Jan 10 at 1:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.