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

Extract wordpress posts content and category content

This’ll output a CSV export of: Post title Post slug Post content Order ID Category ID Pop this in a file in the root of your WordPress install (e.g. export.php), make sure you change the $category_ids with the IDs of all the specific categories. <?php require ‘./wp-load.php’; header( ‘Content-Type: text/csv; charset=” . get_bloginfo( “charset’ ) … Read more