Moderator
t-p
(@t-p)
I recommend asking at https://wordpress.org/support/plugin/wordpress-seo/#new-post so its developers and support community can help you with this.
To add fields to the quick edit form, use the “quick_edit_custom_box” action.
That just lets you output a form field. You need code to save any altered values. The “save_post” action can work for that.
@bcworkz Thank U for help But I m a newbie It would be Really difficult for me to learn nd understand so much In coding All I have done From plugins ,helps and by help of chatgpt.
I Found The Plugin “Custom Bulk/Quick Edit” Which I is quite close to the function I want . It gives additional option like Excerpt field added to quick edit I thought of buying its premium too but I think That plugin owner and team are now not in Touch with that plugin itself. they didn’t even Respond To wordpress blog. So Only thing possible for me is either to go round way or to learn All Things On my own I Thought Sharing Code Here can give me Easy Expert advice about what’s wrong In that code.
add_action( 'quick_edit_custom_box', 'my_quick_edit_custom_box', 999, 2 );
function my_quick_edit_custom_box( $column_name, $post_type ) {
if ( 'yoast_focus_keyword' === $column_name ) {
?>
<fieldset class="inline-edit-col-right inline-edit-yoast-focus-keyword">
<div class="inline-edit-col">
<label>
<span class="title"><?php esc_html_e( 'Yoast Focus Keyword', 'textdomain' ); ?></span>
<span class="input-text-wrap">
<?php $keyphrase = get_post_meta( get_the_ID(), '_yoast_wpseo_focuskw', true ); ?>
<input type="text" name="yoast_focus_keyword" value="<?php echo esc_attr( $keyphrase ); ?>">
</span>
</label>
</div>
</fieldset>
<?php
}
}
add_action( 'save_post', 'my_save_post_custom_field' );
function my_save_post_custom_field( $post_id ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( isset( $_POST['yoast_focus_keyword'] ) ) {
$keyphrase = sanitize_text_field( $_POST['yoast_focus_keyword'] );
update_post_meta( $post_id, '_yoast_wpseo_focuskw', $keyphrase );
}
}
Above Code is created by chatgpt so I can’t understand , Why it’s not working for me I need help on this
I’m sorry, I didn’t investigate this filter thoroughly enough. The ChatGPT code might be fine, I’ve not looked in detail because the filter doesn’t fire at all under default situations. To get it to fire, you need to add your own custom column to the posts list table. Once that is done, then this filter gives you the opportunity to place a field related to the column so users can quick edit that value as well.
Custom columns aren’t that well documented, although there is in fact a page doing so somewhere in WP support docs. However my search-fu is failing me, can’t find it. The original source article the support doc was based upon is linked above.
I realize this is all getting pretty complex for your level of coding skill, but it is what it is. Maybe ChatGPT will come through for you again if you prompt it well 🙂 Good luck!
Well Frankly To Say I Still Didnt Understood What I Really Have to do But I know Code of Chatgpt is correct But incomplete and Rest I found this Link of that plugin I told You earlier Which I tried To explore https://developer.wordpress.org/reference/hooks/manage_post_type_posts_columns/
Again Not being so Good In It I m still confused about what to do adding anoter code to wp-admin/includes/class-wp-posts-list-table.php to post table list or adding another function in function.php with given code of chatgpt . I know chatgpt Will evolve and correct if asked properly So which way should I go Extremely sorry For causing this trouble for u. all i know is I just want to retrieve and update a column from database which is ‘_yoast_wpseo_focuskw’. i don’t even want bulk edit just quick edit for this column bcoz it takes too much time to edit 1000’s of post without focus keyphrase to add one by clicking on edit and adding them while viewing the full post.
Thank u in Advance I will try to find a way or if u could help more on my way then it will be less time consuming for me.
what to do adding anoter code to wp-admin/includes/class-wp-posts-list-table.php
I’m not sure what you actually imagined doing by “adding anoter code”. To be clear, we must never add code to existing WP core files. It’s good practice to never modify any code in WP that’s not our own. All changes to default WP behavior should be done via action and filter hooks. Your own code can reside in its own plugin or child theme.
Unless you can find a plugin to help you add quick edit fields, I don’t see any easier way. Adding to quick edit is even less well documented than adding custom list table columns, whose docs are sparse enough.
An alternative approach to update a DB column would be to use wpdb
class methods to directly update the fields you want to change via mySQL queries. The new values would be included in the update code itself, there’d be no UI to speak of for altering records one at a time.