Query post for today, if no post get the previous one

I think you should make a recursion function that will call itself if there’s no posts found passing new date to query for.. function getDatePosts( $date, $query_args ) { $query_args[‘date_query’] = array( ‘year’ => date( ‘Y’, $date ), ‘mounth’ => date( ‘m’, $date ), ‘day’ => date( ‘d’, $date ) ); $query = new WP_Query( … Read more

update post category in a new table on frequent change of category

You could use an Action Hook ‘save_post‘ to implement the requirement and this way categories will stay synced with your custom table and default tables. Example : function post_updated_sync_category( $post_id ) { //Here you get postid of the post being updated //You can put your code to update in custom table here } add_action( ‘save_post’, … Read more

Show short text of content

One potential issue I see with that is if the content contains Shortcodes. You can strip Shortcodes before passing it to wp_trim_words if you want them removed, or alternately, if you want to maintain them you can apply the Shortcodes beforehand. You may also want to check that $news_item[“post_excerpt”] is not empty, in case a … Read more

Send Newsletter-Email when post changes

You can use a hook developed for such kind of purposes: post_updated Use this hook whenever you need to compare values before and after the post update. Lets get some codding: function mail_on_update($post_ID, $post_after, $post_before){ if($post_after->post_content != $post_before->post_content){ // wp_mail() , mail() here } } add_action( ‘post_updated’, ‘mail_on_update’, 10, 3 ); // 10 – priority, … Read more

Display WordPress Post By Date

i think your question has been answered in here $args = array(‘posts_per_page’ => -1, ‘orderby’ => ‘date’ ); $myQuery = new WP_Query($args); $date=””; if ( $myQuery->have_posts() ) : while ( $myQuery->have_posts() ) : $myQuery->the_post(); if ( $date != get_the_date() ) { echo $date; echo ‘<hr />’; $date = get_the_date(); } the_title(); // or whatever you … Read more