You can use WP_Query like this:
// we get the date for today
$today = getdate();
//we set the variables, i am ignoring sticky posts so they dont get counted
$args = array(
'ignore_sticky_posts' => 1,
'posts_per_page' => -1, //all posts
'date_query' => array(
array(
'year' => $today["year"],
'month' => $today["mon"],
'day' => $today["mday"],
),
),
);
//we create the query
$today_posts = new WP_Query( $args );
//the result already has a property with the number of posts returned
$count = $today_posts->post_count;
//show it
echo $count;
Related Posts:
- Best Practice for PHP
- Adding “Remember Me” in custom login
- Using wp_send_json to return HTML
- WordPress Infinite Scroll without using any plugin
- Add post class to the TinyMCE iframe?
- Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
- How to add query vars with paginated URLs?
- How to remove a metabox from menu editor page?
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- How to Join two tables from separate databases within WordPress
- How to find objects by terms
- Bypass .htaccess when using download_url
- Install will not load: PHP does not have MYSQL installed
- Woocommerce price including tax with formatting from options
- get_template_part not working with ajax
- wordpress inserting posts programatically through a url
- Javascript code inside “” in core WordPress files .php
- How does WooCommerce ensure that a product doesn’t run out of stock during payment? [closed]
- Can I change a variable in a content part while calling it?
- How do you target virtual pages in code?
- Placing the_content inside shortcode not working
- Exclude posts from homepage having a specified tag
- How can I add an alert (like the old javascript alerts) to my WP page?
- How to use transient in this code for related post?
- Why is $_REQUEST an empty array in admin-ajax.php?
- Change output based on text field value
- Change behavior of the tag
- Is it acceptable to treat a filter like an action?
- Where to place PHP code that inserts (or doesn’t insert) menu item?
- Fetch post block/field data as JSON with WordPress API
- How to design a table based on css values set from admin/dashboard
- Get the post ID and display the images
- Where to find documentation for CPT block template? (PHP)
- wp_head function not outputting
- Media upload ERROR Message Showing in BOTTOM of the page wordpress
- Setting default category base on theme activation
- How to manually change current date to post date in frontend?
- WordPress Woocommerce – Product Type [closed]
- Why does wp_head hook my functions to the beginning of my source code?
- Noscript not working as it should in wordpress site
- Pass argument to event hook
- Value prints outside of the echo
- Translate wordpress date from Italian to English
- wp_insert_post: array only. wp_update_post: array|object (?)
- What is the difference in the WP memory limits?
- If ‘editor’ is empty, then
- Different Subdomain changes page content
- Removing the comment function within wordpress
- Does get_post function counts as view?
- Get ACF options field in PHP acting as CSS
- Permalinks are not working in WordPress in digitalocean
- Bootstrap Carousel HTML structure and funny output [closed]
- How to remove custom style from source?
- add category to posts with tag wordpress
- Missing a text-domain esc_attr_e
- Get all posts from categories
- How to add post classes?
- How to Generate a list of Most Commented post?
- Updating From Mobile App – Exposing Site to Hacking
- Extract and display user infromation on an automatically created page
- Why won’t this wpdb get_results query return results?
- How can I assign separate stylesheets to different pages?
- Using multiple variables to assign categories to an array
- Show Custom Menu Name in WordPress 3
- Execute PHP code only with specific user role
- Repeat a function with 24hrs gap for n number of days
- Add a custom WooCommerce settings tab with sections
- How to serve WordPress folder over subdomain?
- How to call my PHP function with AJAX ? wp_query
- Show sidebar only to author of post
- No more get_option(‘date_time’) in WordPress 5.5?
- How to update post content of all posts with tag?
- Create category after theme setup and modify the default one
- Make WooCommerce product categories only show images on homepage
- How to Change Site Elements based on referring URL
- PHP error on local server install
- WP post meta – for loop inside for loop
- Prepared DB Query from _POST array
- How to include non-users in wp-admin redirect?
- WordPress using get_term to retreive slug not working as expected
- auto metakey value on post tile
- Static home page ignored
- How do I routinely extract the thumbnail of the most recent post?
- How to pass parameter that ends up being part of a class name with wordpress shortcode
- WP_Post is not from correct array
- calling a function from a class in your template
- Showing custom field contents without listing description
- Custom single.php files for different post formats
- Troubleshooting “loopback requests that take too long”
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- If I define a variable in header.php, how do I make it available to templates?
- Order woo products, but first products must be with acf fields
- Remove /category/ from category (archive) page URLs (without using a plugin)
- JSON Object Value Show Undefine
- SQL – How to echo out inside of where statement
- How to create different templates for woocommerce single-product.php?
- How can I update a value of a field depending on outside source?
- Restricting access to a file for everyone except logged in users
- WordPress Block Editor Gutenberg running code inside ! is_admin()
- Tags being Inserted in html from plugin PHP not passing through the_content