I want to get recent posts and I use wp_get_recent_posts :

<?php $args = array(
    'numberposts' => '3',
    'post_status' => 'publish',
    'orderby' => 'rand'

$recent_posts = wp_get_recent_posts($args);?>

then I want to show posts info on page:

<?php foreach( $recent_posts as $recent ){?>
        <?php echo the_category('/','',$recent["ID"]); ?>
        <?php echo get_permalink($recent["ID"]) ?>
        <?php echo $recent["post_title"]?></h2>
        <?php echo get_the_date('F j, Y',$recent["ID"])?>
        <?php echo  get_the_post_thumbnail($recent["ID"],'bereza-carousel');?>

But all dynamic data must be correctly escaped. So how can I correctly escape data?


You might want to check out WordPress official docs on this topic, in your case focus on escaping output https://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.