Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show items before or after the current date. #88

Closed
ryanwelcher opened this issue Oct 29, 2024 · 3 comments
Closed

Show items before or after the current date. #88

ryanwelcher opened this issue Oct 29, 2024 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@ryanwelcher
Copy link
Owner

This came from the support forum

@bobbingwide
Copy link

I also have a need for this functionality.
Currently, in order to list Events which are in the future, I use a shortcode called [bw_related] which works in conjunction with a plugin called oik-dates.

On the home page of wp-pompey.org.uk I display the next event - which is a date in the future.
The shortcode I use is

[bw_related post_type="meetup" numberposts=1 
meta_key="_date" order=ASC meta_compare="GE" 
meta_value=. orderby=meta_value format="T/F/E/_" thumbnail=full class=next-event]
  • The custom field _date is a date field, using a string format of YYYY-MM-DD.
  • It's associated with the meetup post type.
  • The meta_value of . indicates that it needs to be replaced by the current date.
  • This is implemented by a filter function attached to oik_default_meta_value_date
  • by the oik-date plugins.
  • The filter function is invoked by the [bw_related] shortcode's logic.

The meta_value attribute could actually be one of the following values.

  • '.' - which tells the code to "use the current value for this field"
  • now
  • today
  • null - for when the attribute's not set.
  • any value that can be passed to date_interval_create_from_date_string( $adjustment )

For another website, I'm currently in the process of switching from an events calendar plugin to my own ( oik-events ) and would like to be able to replace the shortcode solution with a block based solution.

The websites also display a list of past events, with meta_compare=LE

This functionality would therefore be most appreciated as it will save me from attempting to write a similar block to yours.

@ryanwelcher
Copy link
Owner Author

This was addressed in #87

@bobbingwide
Copy link

Out of the box I couldn't directly use the solution implemented by #87 for my particular scenario.
Instead, I implemented a filter function for aql_query_vars, which uses very similar logic to that which I used for my [bw_related] shortcode. It applies the filter oik_default_meta_value_date" on any meta_query with key _date`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants