0

I am creating a plugin that outputs a metabox on each page to be able to assign custom meta descriptions plus some other values. All of that works perfectly.

However, I also have a "bulk editor" options page which displays and outputs everything just fine, but does not save the many values to the assigned meta key or post meta or whatever it is. So everything works fine on all individual pages, and the bulk editor gets all of the values and updates correctly based on individual page changes made, EXCEPT I'm unable to save any or all edits made on the "bulk editor" options page.

How do I go about saving any or all generated values upon page save/update in the bulk update options page? I know I need another function or something but I have tried to piece meal together several things I have seen online and can't wrap my head around how to make it work.

Here is the code for the "Bulk Editor" options page in my plugin:

function my_metas_page() { ?>
<div>
<form method="post" action="options.php">
<h3>Bulk editor for Page Meta Descriptions</h3>
<p>You can bulk edit the Meta Descriptions on this page. Remember to refresh any open pages before updating so you do not undo your changes here.</p>
<?php
settings_fields("my_metas_section");
do_settings_sections("my_metas_options_group");
submit_button();
?>
</form>
</div>
<?php }

function display_my_metas_ids(){
$page_ids=get_all_page_ids();
echo '<h3>Pages :</h3><div style="display:flex;flex-direction:row;flex-wrap:wrap;">';
foreach($page_ids as $page){
echo '<div class="desc-bulk-box" style="width:90%;padding:0 1%;"><strong style="color: #016392;">'.get_the_title($page).'</strong>';// retrieve the _metadescs current value
if ('draft' === get_post_status( $page )) {echo '<em> (in draft mode)</em>';}
$current_metadescs = get_post_meta( $page, '_metadescs', true ); ?>
    <textarea rows="2" cols="90" name="metadescs" placeholder="Enter Your Meta Description Here, Otherwise, An Excerpt Will Be Displayed" style="color:#016392;max-width:100%;width:100%;"><?php echo $current_metadescs; ?></textarea>
    </div>
<?php
}
}

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.