This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addComment(){ | |
global $wpdb; | |
//get a random post | |
$args=array('post_type'=>'post', 'orderby'=>'rand', 'posts_per_page'=>'1'); | |
$mypost=new WP_Query($args); | |
while ($mypost->have_posts()) : $mypost->the_post(); | |
$mypost_id = $post->ID; | |
endwhile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addComment(){ | |
global $wpdb; | |
$slug = 'YOUR_SLUG'; //the slug of your post where you want to insert comments | |
$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$slug'"); //retrieve id of the post | |
$comentarios = array(); //custom array of comments to insert...please fill in with your values | |
$nombres = array(); //custom array of names to insert...please fill in with your values |