array_rand not working correctly?

Getting a single random post would be far more efficient than getting all posts, then plucking a random post from the query. Here’s an updated WP_Query instance using ‘orderby’ => rand: $args = array( ‘orderby’ => ‘rand’, ‘posts_per_page’ => ‘1’, ‘paged’ => $paged, ‘post_type’ => ‘Didyouknows’, // Post type names should never use capital letters, … Read more

Why excerpt is Displaying same in Random Posts list

You are trying to use the_title() and the_excerpt() functions outside the wordpress loop, therefore, they will not work. I suggest you try something like : $args = array( ‘posts_per_page’ => 12, ‘orderby’ => ‘rand’, ‘post_status’ => ‘publish’, ‘offset’ => 1); $query = new WP_Query($args); while($query->have_posts()){ $query->the_post(); // the_excerpt() will now work as expected }

How to show different timestamp

This should do it. // See if the post is older than 24 hours. if ( get_post_time() <= strtotime( ‘-1 day’ ) ) { echo ‘Published more than 24 hours ago.’; } else { echo ‘Published within the last 24 hours.’; }

Send email for pending post

I did a bit more research and this is what is working for me now. The admin will only get an update if a pending post is added or updated. add_action( ‘transition_post_status’, ‘pending_post_status’, 10, 3 ); function pending_post_status( $new_status, $old_status, $post ) { if ( $new_status === “pending” ) { $post_title = get_the_title( $post_id ); … Read more