بابه‌ت: کۆدیی زۆرترین بینراو کێشەیی هەیە :(

ئەم کۆدە بەکا دەبەم بۆ ئەوەیی زۆرترین بینراو دابنێم بە بێپلەگین بۆیە هەموویی دەنوسرێ ٠ بینراو

function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 خوێنراوە";
    }
    return $count.' خوێنراوە';
}
function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}

وە بۆ بانگکردنیی ئەمە بەکاردێنم

<?php
                          echo getPostViews(get_the_ID());
                ?>

وه‌ڵام: کۆدیی زۆرترین بینراو کێشەیی هەیە :(

تۆ تەنها بانگی ژمارەی بینراو دەکەیت پێویستە کردیاری ژماردنی ییش دابنێت تاکوو هەردوو فەرمانەکان جێ بەجێ ببن

نمونە

<?php
    setPostViews(get_the_ID());
    echo getPostViews(get_the_ID());
?>
هۆست و دۆمەین لە باشترین راژەی کوردی www.hostchin.org
<?php $var="Ayman"; echo preg_match("/Ayman/",$var) ? "He is  Okay smile" : "He is not Ayman";?>

وه‌ڵام: کۆدیی زۆرترین بینراو کێشەیی هەیە :(

سوپاس کاک ئەیمەن