How to filter items out of sitemap using custom code

Created on 10 July 2023, over 1 year ago
Updated 27 August 2024, 4 months ago

We would like to have a custom sitemap that only includes items of a certain content type that were created within a certain time frame. I was hoping to get a nudge in the right direction. For example, we would like to include only "article" nodes that were created before January 1st 2023. My questions are:

1. Is this possible using one of the hooks provided by this module?
2. If so, can anyone point me to an example of usage of the hook?

Thank you for any tips!

πŸ’¬ Support request
Status

Fixed

Version

4.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brockfanning

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @brockfanning
  • πŸ‡ΊπŸ‡ΈUnited States merauluka

    I just recently was able to do this by creating a custom URL Generator based on the EntityUrlGenerator plugin.

    There you can alter the entity query used to identify which entities you wish to have included in the final result set. I used it to key off of a custom boolean on my site. That way I could intentionally exclude content based on whatever I wanted.

    And since it's using an entity query, you can query based on anything the entity query system and access.

  • Status changed to Fixed 4 months ago
  • πŸ‡©πŸ‡ͺGermany gbyte Berlin

    Either create a new URL generator by code and use it within the UI or just use the sitemap links alter hook (see Readme) to filter out entities beyond a certain creation date.

    When it comes to having certain content types indexed in certain sitemap, this is already possible without custom code.

    Let me know if yiu need further pointers.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024