Skip to content

Instantly share code, notes, and snippets.

View garciasanchezdani's full-sized avatar
😎

Daniel garciasanchezdani

😎
View GitHub Profile
@garciasanchezdani
garciasanchezdani / wp-add-comment.php
Last active August 29, 2015 14:20
Script which insert comments to a random post of wordpress - by using the core wordpress comments
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;
@garciasanchezdani
garciasanchezdani / wp-add-comment-rich-reviews.php
Created April 27, 2015 07:45
Script which insert comments to a post of wordpress - by using the plugin rich reviews
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