Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add date_query support #77
As requested in #38, this PR implements date_query support for a single date query.
This would be considered "phase 1" with the option to later add support for incremented (multiple) date queries. The reasoning for not including multiples with this PR, is that while the logical progression is to move to supporting multiples in the future, it would probably be best to first nail down the best approach to implementing a single date query in terms of attribute naming and architecture :)
Note: In the attribute descriptions below, you'll notice that I reference the "top-level" and "second-level" areas of the date query. Top-level arguments serve in a "global" capacity to all date queries contained on the second-level. The actual individual date queries are defined on the second-level of the associative array.
This introduces a total of 8 new attributes (yikes, I know):
It also introduces a new function,
Here are some sample shortcodes:
Query for posts published after January 1, 2013:
Query for posts published BEFORE today:
Query for posts modified yesterday:
I'm a little on the fence about the attribute naming. It's clear there needs to be a logical division between the top-level and second-level attributes, though things could easily get pretty long once you start thinking about 1) using multiple date query attributes in a single shortcode 2) eventually incrementing those attributes for multiple date queries.
In the vein of multiple queries, we could probably forgo introducing the second-level
"phase 2" would then introduce
Something to think about.
I got syntax errors from the variables defined within an if statement. Ex: https://github.com/DrewAPicture/display-posts-shortcode/blob/datequery/display-posts-shortcode.php#L164 Breaking it apart into $variable = whatever; if ( ! empty( $variable ) ) fixed it for me.
But other than that, it worked great!
added a commit
this pull request
Sep 10, 2014
I have applied in this date code in the following way
[display-posts date="today" category="Dawn" no_posts_message="No Job Published in Dawn Newspapers Today." posts_per_page="150"]
but this is not working so I have applied the following as usual
[display-posts date="2018-12-12" category="Dawn" no_posts_message="No Job Published in Dawn Newspapers Today." posts_per_page="150"]
I am using IsleMag theme and This plugin has not been tested with version of WordPress.
Plz spend your precious time for this issue. And tell me how to fix it....
I have applied the following code and see the result in attached picture