php – How can I change the location where the custom field is displayed in the Quick Edit tab in WordPress
Question
That’s my situation right now:
I want to display my “Artist” custom field under the “Slug” field, with the same HTML structure. But how? Example:
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.
0
1 month
2023-01-05T11:27:35-05:00
2023-01-05T11:27:35-05:00 0 Answers
0 views
0
Leave an answer