wmaraci reklam

Wordpress Yorum Tarihlerini Random Yapabilecek Bir Eklenti Yapmak

2 Mesajlar 442 Okunma
pst.net
wmaraci reklam

CloumDigital CloumDigital Cloum.com Kullanıcı
  • Üyelik 27.03.2014
  • Yaş/Cinsiyet 24 / E
  • Meslek Dijital Reklam Uzmanı
  • Konum İstanbul Avrupa
  • Ad Soyad Ç** K**
  • Mesajlar 1534
  • Beğeniler 184 / 336
  • Ticaret 68, (%100)
Wordpress'de paylaşıma/ürüne gelen yorumların tarihini random yapmak istiyorum. İnternette biraz araştırdım ama bulabildiğim en benzer örnek post tarihlerini random yapan bir eklenti, o da şöyle;

/**
* Plugin Name: WP Post Random Dates
* Description: On activation, change the dates of all posts to random dates
*/

//* We want to do this only once, so add hook to plugin activation
register_activation_hook( __FILE__ , 'wpse_259750_activation' );
function wpse_259750_activation() {

//* Get all the posts
$posts = get_posts( array( 'numberposts' => -1, 'post_status' => 'any' ) );
foreach( $posts as $post ) {

//* Generate a random date between January 1st, 2015 and now
$random_date = mt_rand( strtotime( '1 January 2018' ), time() );
$date_format = 'Y-m-d H:i:s';

//* Format the date that WordPress likes
$post_date = date( $date_format, $random_date );

//* We only want to update the post date
$update = array(
'ID' => $post->ID,
'post_date' => $post_date,
'post_date_gmt' => null,
);

//* Update the post
wp_update_post( $update );
}
}


Ben bunu yorumları randomlamak için kullanmak istiyorum, ne yapabilirim? Hem tarihi hem de saati randomlaması gerekiyor.
 

 

wmaraci
reklam

YORci YORci yorci.com Kullanıcı
  • Üyelik 06.02.2016
  • Yaş/Cinsiyet 29 / E
  • Meslek Arkaplan Yazılım
  • Konum Ankara
  • Ad Soyad I** Y**
  • Mesajlar 261
  • Beğeniler 88 / 127
  • Ticaret 21, (%100)
bu kişiliksize yardım etmeyi geçtim, fikir vermek bile fazla.
 

 

wmaraci
Konuyu toplam 1 kişi okuyor. (0 kullanıcı ve 1 misafir)
Site Ayarları
  • Tema Seçeneği
  • Site Sesleri
  • Bildirimler
  • Özel Mesaj Al