• Hello, please i need your help updating the featured status with a button on the frontend.

    Here is my try;

    // Mark Featured Button	
    <form action="/ngodirectory/dashboard" method="POST" name="front_end_featured" class="ogdform"><input id="fbtn" type="hidden" name="fbtn" value="'.$post->ID.'" />
    <input id="FEATURED_BTN" type="hidden" name="FEATURED_BTN" value="FEATURED_BTN" />
    <button class="directorist-btn directorist-btn-primary" id="featured" type="submit" name="submit" value="Promote"><i class="%s-ad"></i> Mark Featured </button></form>
    function mywpupdate_post_meta($post_id,$key){
    	$thispost = get_post( $post_id, 'ARRAY_A' );
    	$thispost['_is_ns_featured_post'] = $key;
    	wp_update_post_meta($thispost);
    }
    
    if (isset($_POST['FEATURED_BTN']) && $_POST['FEATURED_BTN'] == 'FEATURED_BTN'){
    if (isset($_POST['fbtn']) && !empty($_POST['fbtn'])){
    mywpupdate_post_meta((int)$_POST['fbtn'],'yes');}}
  • The topic ‘Update featured meta key with form’ is closed to new replies.