Skip to content

Add a Code Library snippet for older-than-source CRP results #1

Description

@ajaydsouza

Goal

Add a copy-and-paste Code Library example that restricts Contextual Related Posts results to posts published before the current source post.

Existing coverage

The existing crp-change-query-dates.php example demonstrates crp_query_date_query for same-day matching. It does not cover older-than-source behavior, which is the practical snippet-level alternative to YARPP's past_only option.

Deliverables

  • Add contextual-related-posts/crp-older-posts.php or an equally clear filename under the queries category.
  • Use crp_query_date_query and derive the source post publication date safely from the query arguments or current post.
  • Define and document the boundary behavior so posts published after the source are excluded.
  • Add a uniquely prefixed callback, PHPDoc, and matching Markdown companion under src/content/snippets/contextual-related-posts/.
  • Include the timezone and timestamp-precision caveat needed for a reliable date comparison.
  • Set requiresPro: false, list the correct requirements, and link the crp_query_date_query hook reference.

This should remain a focused query example; it should not add a CRP setting or attempt to implement YARPP compatibility in the plugin.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions