Create a daily post programatically
-
Hi there, I can’t find any topic discussing my needs, so I create this topic.
My needs: automatically create a daily post with the summary of all the posts published in the last 24 hours.
What I can do so far:- I have created a shortcode that returns an unordered list with all the linked titles of the posts published in the last 24 hours. If I echo that shortcode on php I can see the list.
- I can create a new post with the title desired (including the day-month-yar of creation) using wp_insert_post().
What I can not do (so in this I need help):
- To insert in the post_content attribute the shortcode (I include the code used for the wp_insert_post)
- That every day at 20:00 WP creates a new post using the wp_insert_post().
This is the code I use to create the new post:
<?php $content = do_shortcode( '[summary]' ); $date = date("d/m/Y"); $title_post = "Resumen diario - " .$date; $id = wp_insert_post(array( 'post_title'=>$title_post, 'post_type'=>'resumen', 'post_status'=>'publish', 'post_content'=> $content, )); ?>
Thanks a lot for your help.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Create a daily post programatically’ is closed to new replies.