How can I get a table with the number of published posts by date?

the fastest way imho would be to create a custom sql statement: global $wpdb; $rows = $wpdb->query(‘SELECT DATE(post_date) AS date, COUNT(*) AS count FROM ‘ . $wpdb->posts . ‘ GROUP BY DATE(post_date) ORDER BY DATE(post_date)’); foreach ($rows as $row) { echo $row->date . ‘: ‘ . $row->count . ‘<br>’; }

Make post_content and other custom fields required

Don’t rely entirely on JavaScript validations. Use below hook for Server side validation. function check_if_post_content_set( $maybe_empty, $postarr ) { // Check if post is already created. IMPORTANT if($postarr[‘ID’] && (int)$postarr[‘ID’] > 0){ if( !$postarr[‘post_content’] OR $postarr[‘post_content’] == ” OR $postarr[‘post_content’] == NULL ){ $maybe_empty = true; } } return $maybe_empty; } add_filter( ‘wp_insert_post_empty_content’, ‘check_if_post_content_set’, 999999, … Read more

how to bulk add one line in the first paragraph of all posts

I’d go for solution posted by @butlerblog – it’s a lot easier to manage and change in the future and it’s better WP practice. But… If you’re asking… Here are the ways you can do this: 1. WP way: function prepend_content_to_posts() { $to_prepend = ‘This will be prepended’; $posts = get_posts( array( ‘posts_per_page’ => -1 … Read more

transition_post_status hook doesn’t have any POST data when publish with Gutenberg [closed]

But you shouldn’t use $_POST inside that hook. transition_post_status fires when a post is transitioned from one status to another. It can be caused by anything (not only by sending POST request from editor). For example here’s the function that is responsible for publishing future posts: check_and_publish_future_post. It’s called only by cron, without sending any … Read more

Remove a shortcode from all WordPress posts

I love to use this tool, Search and Replace for WordPress Databases. It is basically a PHP script that is written for WordPress usage (but of course can be used with any database). When placed in the WordPress project, it automatically detects and loads the Database using data from wp-config.php file. It enables you to … Read more

How to setup a query to output posts by groups of five?

you can create a simple counter and condition: <?php $count = 0; ?> <?php if( $query->have_posts() ) : ?> <ul class=”posts”> <?php while ( $query->have_posts() ) : $query->the_post(); if ($count < 5){ ?> <li> <?php the_title(); ?> </li> <?php }else{ echo ‘</ul><ul class=”posts”>’; ?> <li> <?php the_title(); ?> </li> <?php $count = 0; } $count … Read more

Do action on publish or update?

Why don’t you wrap it in post save_post and post_publish hooks? You have examples here: http://codex.wordpress.org/Function_Reference/add_action How to do it: Add this to your functions.php file: function my_data_update () { $company = get_field(‘company_name’); $address = get_field(‘address’); $city = get_field(‘city’); $post_code = get_field(‘post_code’); //etc etc… } add_action(‘publish_post’, ‘my_data_update’); add_action(‘save_post’, ‘my_data_update’);