I'm trying to add a wordpress filter to the posting area:
AndIwantedtoseeonlypoststhathavethisfunctionapplied:
functionag_display_custom_meta_box($post){wp_nonce_field('ag_featured_custom_box','ag_featured_custom_box_nonce');$stored=get_post_meta($post->ID,'_ag_featured_post',true);$options=array('0'=>'Nãousarmatériacomodestaque','principal'=>'Grande','secundaria'=>'Pequenos','slider'=>'Slider','colunaaposentados'=>'ColunaAposentados','colunaunidades'=>'ColunaUnidades','colunaeventos'=>'ColunaEventos','colunaesportes'=>'ColunaEsportes','colunanoticias'=>'ColunaNoticias','colunafenae'=>'ColunaFenae');$output="<select name='ag_featured_post_position'>";
foreach ($options as $value => $title):
$output .= "<option ";
if(esc_attr($stored) == $value)
$output .= "selected='selected' ";
$output .= "value='{$value}'>{$title}</option>";
endforeach;
$output .= "</select>";
echo $output;
}
/**
* @param $post_id
*/
function ag_save_meta_box( $post_id ) {
// Validations
$nonce = $_POST['ag_featured_custom_box_nonce'];
if(!isset($_POST['ag_featured_post_position']) || !wp_verify_nonce($nonce, 'ag_featured_custom_box'))
return $post_id;
if(defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE)
return $post_id;
// Check the user's permissions
if ( 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) ) {
return $post_id;
}
} else {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
}
update_post_meta( $post_id, '_ag_featured_post', sanitize_text_field(
$_POST['ag_featured_post_position']));
}
add_action('save_post', 'ag_save_meta_box');
I've read something about add_filter , but I do not know where to apply and where to put exactly ...
The exact use of this filter is: on my site there is a 'highlight' area that uses this function to choose what goes and what does not go there ... the problem that I have countless daily posts and are not all that go to the spotlight, and the posting staff would like to filter only the ones that stand out ... and I do not know how to do that.
As it is in wordpress the doc I read commented on being in the function.php file